<commit_before><?php

class AuthRemoteUserExtension extends Extension {

	/**
	 *
	 * @var Boolean Whether to create a new user if the credential is not recognized.
	 */
	private static $auto_create_user = false;

	/**
	 *
	 * @var string The group to which to add auto-created users.
	 */
	private static $auto_user_group = null;

	/**
	 * Set whether to create a new user if the credential is not recognized.
	 *
	 * @param Boolean $setting
	 */
	public static function setAutoCreateUser($setting) {
		AuthRemoteUserExtension::config()->auto_create_user = (bool) $setting;
	}

	/**
	 * Set the group name for auto-created users.
	 *
	 * @param string $group_name A valid group name
	 */
	public static function setAutoUserGroup($group_name) {
		AuthRemoteUserExtension::config()->auto_user_group = $group_name;
	}

	/**
	 * If the REMOTE_USER is set and is in the Member table, log that member in. If
	 * not, and AuthRemoteUserExtension::config()->auto_create_user is set, add that
	 * Member to the configured group, and log the new user in. Otherwise, do nothing.
	 */
	public function onAfterInit() {
		if (isset($_SERVER['REMOTE_USER'])) {
			$unique_identifier = $_SERVER['REMOTE_USER'];
			$unique_identifier_field = Member::config()->unique_identifier_field;
			$member = Member::get()->filter($unique_identifier_field, $unique_identifier)->first();
			if ($member) {
				$member->logIn();
			}
			elseif (AuthRemoteUserExtension::config()->auto_create_user &&
					strlen(AuthRemoteUserExtension::config()->auto_user_group)) {
				$group = Group::get()
					->filter('Title', AuthRemoteUserExtension::config()->auto_user_group)->first();
				if ($group) {
					$member = new Member();
					$member->$unique_identifier_field = $unique_identifier;
					$member->write();
					$member->Groups()->add($group);
					$member->logIn();
				}
			}
		}
	}

}<commit_msg>Fall back to REDIRECT_REMOTE_USER<commit_after><?php

class AuthRemoteUserExtension extends Extension {

	/**
	 *
	 * @var Boolean Whether to create a new user if the credential is not recognized.
	 */
	private static $auto_create_user = false;

	/**
	 *
	 * @var string The group to which to add auto-created users.
	 */
	private static $auto_user_group = null;

	/**
	 * Set whether to create a new user if the credential is not recognized.
	 *
	 * @param Boolean $setting
	 */
	public static function setAutoCreateUser($setting) {
		AuthRemoteUserExtension::config()->auto_create_user = (bool) $setting;
	}

	/**
	 * Set the group name for auto-created users.
	 *
	 * @param string $group_name A valid group name
	 */
	public static function setAutoUserGroup($group_name) {
		AuthRemoteUserExtension::config()->auto_user_group = $group_name;
	}

	/**
	 * If the REMOTE_USER is set and is in the Member table, log that member in. If
	 * not, and AuthRemoteUserExtension::config()->auto_create_user is set, add that
	 * Member to the configured group, and log the new user in. Otherwise, do nothing.
	 */
	public function onAfterInit() {
		if (isset($_SERVER['REMOTE_USER'])) {
			$unique_identifier = $_SERVER['REMOTE_USER'];
		}
		elseif (isset($_SERVER['REDIRECT_REMOTE_USER'])) {
			$unique_identifier = $_SERVER['REDIRECT_REMOTE_USER'];
		}
		if (isset($unique_identifier)) {
			$unique_identifier_field = Member::config()->unique_identifier_field;
			$member = Member::get()->filter($unique_identifier_field, $unique_identifier)->first();
			if ($member) {
				$member->logIn();
			}
			elseif (AuthRemoteUserExtension::config()->auto_create_user &&
					strlen(AuthRemoteUserExtension::config()->auto_user_group)) {
				$group = Group::get()
					->filter('Title', AuthRemoteUserExtension::config()->auto_user_group)->first();
				if ($group) {
					$member = new Member();
					$member->$unique_identifier_field = $unique_identifier;
					$member->write();
					$member->Groups()->add($group);
					$member->logIn();
				}
			}
		}
	}

}
{'fraction_non_alphanumeric': 0.13527309851965288, 'fraction_numerical': 0.0, 'mean_word_length': 4.116187989556136, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6333570', 'n_tokens_mistral': 1330, 'n_tokens_neox': 1150, 'n_words': 307}