FOC\Authenticate\Auth\MultiColumnAuthenticate::_findUser PHP Méthode

_findUser() protected méthode

Find a user record using the standard options.
protected _findUser ( string $username, string $password = null ) : boolean | array
$username string The username/identifier.
$password string The password, if not provide password checking is skipped and result of find is returned.
Résultat boolean | array Either false on failure, or an array of user data.
    protected function _findUser($username, $password = null)
    {
        $userModel = $this->_config['userModel'];
        list($plugin, $model) = pluginSplit($userModel);
        $fields = $this->_config['fields'];
        $conditions = [$model . '.' . $fields['username'] => $username];
        $columns = [];
        foreach ($this->_config['columns'] as $column) {
            $columns[] = [$model . '.' . $column => $username];
        }
        $conditions = ['OR' => $columns];
        if (!empty($this->_config['scope'])) {
            $conditions = array_merge($conditions, $this->_config['scope']);
        }
        $table = TableRegistry::get($userModel)->find('all');
        if ($this->_config['contain']) {
            $table = $table->contain($this->_config['contain']);
        }
        $result = $table->where($conditions)->hydrate(false)->first();
        if (empty($result)) {
            return false;
        }
        if ($password !== null) {
            $hasher = $this->passwordHasher();
            $hashedPassword = $result[$fields['password']];
            if (!$hasher->check($password, $hashedPassword)) {
                return false;
            }
            $this->_needsPasswordRehash = $hasher->needsRehash($hashedPassword);
            unset($result[$fields['password']]);
        }
        return $result;
    }
MultiColumnAuthenticate