This method should handle any login logic and report back to the subject.

@param 	array 	holds the user data
@param 	array    extra options

@return bool True on success
434342
public function onBeforeLoginPerson(AnEvent $event)
    {
        $credentials = $event->credentials;

        if (! $this->_canPerform()) {
            return false;
        }

        if (isset($credentials['username'])) {
            $this->_createToken($credentials['username']);
        }
    }
1201105
protected function _afterLogin(array $userData, &$targetUrl) {
        if ($loginHelper = $this->_getLoginHelper()) {
            $loginHelper->afterLogin($userData, $targetUrl);
        }
    }
678509
public function createLoginForm($options = array())
		{

			// Default options
			$options = array_merge(array(
				"action" => $this->loginUri,
				"method" => "post"
			), $options);

			// Create it!
			$form = new Form($options);

			// Done.
			return $form;

		}
876269
protected function _loginUser($username, $data = array())
    {
        $data['username'] = $username;

        $parameter        = JFactory::getApplication()->isAdmin() ? 'admin_language' : 'language';
        $data['language'] = $this->getObject('user.provider')->load($username)->get($parameter);

        $options = $this->_options;

        JPluginHelper::importPlugin('user');
        $results = JFactory::getApplication()->triggerEvent('onUserLogin', array($data, $options));

        // The user is successfully logged in. Refresh the current user.
        if (in_array(false, $results, true) == false)
        {
            parent::_loginUser($username);
            return true;
        }

        return false;
    }
1237789
public function fromArray($options)
    {
        if (isset($options['AccountId'])) {
            Validate::isString($options['AccountId'], 'options[AccountId]');
            $this->_accountId = $options['AccountId'];
        }

        if (isset($options['ReservedUnitType'])) {
            Validate::isInteger($options['ReservedUnitType'], 'options[ReservedUnitType]');
            $this->_reservedUnitType = intval($options['ReservedUnitType']);
        }

        if (isset($options['MaxReservableUnits'])) {
            Validate::isInteger($options['MaxReservableUnits'], 'options[MaxReservableUnits]');
            $this->_maxReservableUnits = intval($options['MaxReservableUnits']);
        }

        if (isset($options['CurrentReservedUnits'])) {
            Validate::isString($options['CurrentReservedUnits'], 'options[CurrentReservedUnits]');
            $this->_currentReservedUnits = intval($options['CurrentReservedUnits']);
        }
    }
204287
public function setLoginData(array $data)
    {
        $data = Helpers::parseLoginData($data);
        $this->getUser()->setLoginData($data[User::ID_LOGIN], $data[User::ID_ROLE], $data[User::ID_UNIT], $data[User::LOGOUT_DATE]);
    }
734270
public function removePostDataSet ($array) {
		if (!Arrays::IsTraversable($array)) {
			return false;
		}
		foreach ($array as $name) {
			if (isset($this->request->data->$name)) {
				Request::RemovePostData($name);
				unset($this->request->data->$name);
			}
		}
		return true;
	}
70022
public function evaluate(array $options)
    {
        $request = $this->requestStack->getCurrentRequest();
        $referrer = $request->headers->get('referer');
        if ($this->referrerHeader && $request->headers->has($this->referrerHeader)) {
            $referrer = $request->headers->get($this->referrerHeader);
        }

        return (bool) preg_match(
            '/^' . str_replace(['*', '/'], ['(.*)', '\/'], $options[static::REFERRER]) . '$/',
            $referrer
        );
    }
1010721
function process_request (&$request)
    {
        if(isset($request->user) && !$request->user->isAnonymous()){
            return false;
        }
        if (! isset($request->SERVER['PHP_AUTH_USER'])) {
            return false;
        }
        
        $auth = array(
                'login' => $request->SERVER['PHP_AUTH_USER'],
                'password' => $request->SERVER['PHP_AUTH_PW']
        );
        foreach (Pluf::f('auth_backends', 
                array(
                        'User_Auth_ModelBackend'
                )) as $backend) {
            $user = call_user_func(
                    array(
                            $backend,
                            'authenticate'
                    ), $auth);
            if ($user !== false) {
                break;
            }
        }
        if($user){
            $request->user = $user;
        }
        return false;
    }
90141
public function attempt($options = [])
    {
        if (empty($options)) {
            throw new \Exception('You must provide the login credentials!');
        }

        $db = new Database();
        $cap = $db->getCapsule();

        $table = $cap->table($this->_config->get('auth_table'));

        $keys = [];

        foreach ($options as $key => $value) {
            $keys[] = $key;
        }

        $user = $table->where($keys[0], '=', $options[$keys[0]]);

        if ($user->count() > 0) {
            $user = $user->first();
            $keys1 = $keys[1];
            if ($user->$keys1 == $options[$keys1]) {
                $iv = $this->_ssl->random_string(16);
                $this->_session->set('_token', $this->_ssl->tokenize($iv));
                $this->_session->set('auth', $this->_ssl->tokenize($iv, $user->id));
                $this->_session->set('expire', time() + (((60 * 60) * 24) * 30));
                $this->_session->set('_token_meta', $iv);

                return true;
            }
        }

        return false;
    }
621219
public static function form_select($name = '', $options = array(), $selected = array(), $extra = '')
    {
        if (! is_array($selected)) {
            $selected = array($selected);
        }

        // If no selected state was submitted we will attempt to set it automatically
        if (count($selected) === 0) {
            // If the form name appears in the $_POST array we have a winner!
            if (isset($_POST[$name])) {
                $selected = array($_POST[$name]);
            }
        }

        if ($extra != '') {
            $extra = ' '.$extra;
        }

        $multiple = (count($selected) > 1 && strpos($extra, 'multiple') === false) ? ' multiple="multiple"' : '';

        $form = '<select name="'.$name.'" id="'.$name.'"'. $extra.$multiple .">\n";

        foreach ($options as $key => $val) {
            $key = (string) $key;

            if (is_array($val)) {
                $form .= '<optgroup label="'.$key.'">'."\n";

                foreach ($val as $optgroup_key => $optgroup_val) {
                    $sel = (in_array($optgroup_key, $selected)) ? ' selected="selected"' : '';

                    $form .= '<option value="'.$optgroup_key.'"'.$sel.'>'.(string) $optgroup_val."</option>\n";
                }

                $form .= '</optgroup>'."\n";
            } else {
                $sel = (in_array($key, $selected)) ? ' selected="selected"' : '';

                $form .= '<option value="'.$key.'"'.$sel.'>'.(string) $val."</option>\n";
            }
        }

        $form .= '</select>';

        return $form;
    }
285922
public function save($options = array())
    {

        if ($this->isEmbed()) {
            return false;
        }

        $this->processReferencesChanged();
        $this->processEmbedsChanged();

        /* if no changes then do nothing */

        if ($this->_exist && empty($this->dirtyData) && empty($this->unsetData)) return true;

        $this->__preSave();

        if ($this->_exist) {
            $this->__preUpdate();
            $updateQuery = array();

            if (!empty($this->dirtyData)) {
                $updateQuery['$set'] = self::mapFields($this->dirtyData);
            };

            if (!empty($this->unsetData)) {
                $updateQuery['$unset'] = self::mapFields($this->unsetData);
            }

            $success = $this->_connection->update($this->collectionName(), array('_id' => $this->getId()), $updateQuery, $options);
            $this->__postUpdate();

        } else {
            $this->__preInsert();
            $data = self::mapFields($this->cleanData);
            $insert = $this->_connection->insert($this->collectionName(), $data, $options);
            $success = !is_null($this->cleanData['_id'] = $insert['_id']);
            if ($success) {
                $this->_exist = true ;
                $this->__postInsert();
            }

        }

        $this->dirtyData = array();
        $this->unsetData = array();
        $this->__postSave();

        return $success;

    }
1204057
public function checkIntegrity()
    {
        $combine = array_merge(['put' => array_diff_assoc($_SESSION, $this->sessionHandler->all())],['forget' => array_keys(array_diff_assoc($this->sessionHandler->all(), $_SESSION))]);
        if ($combine) {
            foreach($combine as $method => $dataArray) {
                if (!empty($dataArray)) {
                    $this->sessionHandler->$method($dataArray);
                }
            }
        }
        return true;
    }
1234638
private function addUsers($users)
    {
        if (!is_array($users)) {
            return false;
        }

        foreach ($users as $username => $data) {
            if ($username == '' || !$this->isString($username)) {
                throw new MemoryException('Cannot store a user that doesn\'t have a username.');
            }

            if (!isset($data['password'])) {
                $data['password'] = '';
            }

            if (!isset($data['roles']) || empty($data['roles'])) {
                $data['roles'] = [];
            } else {
                $data['roles'] = (array)$data['roles'];
            }

            $this->users[$username] = $data;
        }

        return true;
    }
461631
public function change(
		User $user,
		$add = [],
		$remove = [],
		array $extraParams = []
	) {
		$result = $this->api->postRequest(
			new SimpleRequest(
				'query', [
				'list' => 'users',
				'ustoken' => 'userrights',
				'ususers' => $user->getName(),
			]
			)
		);

		$params = [
			'user' => $user->getName(),
			'token' => $result['query']['users'][0]['userrightstoken'],
		];
		if ( !empty( $add ) ) {
			$params['add'] = implode( '|', $add );
		}
		if ( !empty( $remove ) ) {
			$params['remove'] = implode( '|', $remove );
		}

		$this->api->postRequest(
			new SimpleRequest( 'userrights', array_merge( $extraParams, $params ) )
		);

		return true;
	}
1346939
public function loginUser($user = null, $properties = array())
    {
        if($this->_login_user && $user)
        {
            //Get the user data
            if(!is_array($user))
            {
                if($user instanceof UserInterface) {
                    $user = $user->toArray();
                } else {
                    $user = $this->getObject('user.provider')->getUser($user)->toArray();
                }
            }

            //Set the user properties
            $properties = array_merge($properties, (array) $user);

            $this->getObject('user')->setProperties($properties);
            $this->getObject('user')->setAuthentic();

            return true;
        }

        return false;
    }
989076
public function validate(array $input): bool
    {
        // Grab input fields and define the rules for user validations.
        $rules = [
            'email' => ['required', 'email'],
            'password' => ['required'],
            'fullname' => ['required'],
            'site_name' => ['required'],
        ];

        $validation = \app('validator')->make($input, $rules);

        // Validate user registration, we should stop this process if
        // the user not properly formatted.
        if ($validation->fails()) {
            throw new ValidationException($validation);
        }

        return true;
    }