Determine if the user matches the credentials.

@param  mixed  $user
@param  array  $credentials
@return bool
436744
protected function hasValidCredentials($user, $credentials)
    {
        return ! is_null($user) && $this->provider->validateCredentials($user, $credentials);
    }
1195260
public function authenticate(Authenticatable $user, array $credentials)
    {

        $handler = ldap_connect($this->host);

        if (! $handler) {
            throw new RuntimeException("Connection fail! Check your server address: '{$this->host}'.");
        }

        try {
            ldap_set_option($handler, LDAP_OPT_PROTOCOL_VERSION, 3);
        } catch (\ErrorException $e) {
            ;
        }

        $username = strtok($user->email, '@');

        $rdn = $this->makeRdn($username);

        try {
            $bind = ldap_bind($handler, $rdn, $credentials['password']);
        } catch (\ErrorException $e) {
            $bind = false;
        }

        if ($handler) {
            ldap_close($handler);

            unset($handler);
        }

        if ($bind) {
            $user->save();
        }

        return $bind;
    }
1100656
protected function validateReset(array $credentials)
    {
        if (is_null($user = $this->getUser($credentials))) {
            return static::INVALID_USER;
        }

        if (! $this->validateNewPassword($credentials)) {
            return static::INVALID_PASSWORD;
        }

        if (! $this->validateToken($user, $credentials)) {
            return static::INVALID_TOKEN;
        }

        if (! $this->validateTimestamp($credentials['expiration'])) {
            return static::EXPIRED_TOKEN;
        }

        return $user;
    }
384967
public function retrieveByCredentials(array $credentials) {

        $conditions = [];

        foreach ($credentials as $key => $value) {
            if (!str_contains($key, 'password')) {
                $conditions[$key] = $value;
            }
        }
        $user = $this->createEmptyUserRecord()->fromDb($conditions, [], $this->getRelationsToFetch());

        return $this->validateUser($user, null);
    }
223217
public function validateCredentials(Authenticatable $user, array $credentials)
    {
        if (! app('hash')->check($credentials['password'], $user->password)) {
            return false;
        }

        return true;
    }
175890
public function findByCredentials(array $credentials)
	{
		$model     = $this->createModel();
		$loginName = $model->getLoginName();

		if ( ! array_key_exists($loginName, $credentials))
		{
			throw new \InvalidArgumentException("Login attribute [$loginName] was not provided.");
		}

		$passwordName = $model->getPasswordName();

		$query              = $model->newQuery();
		$hashableAttributes = $model->getHashableAttributes();
		$hashedCredentials  = array();

		// build query from given credentials
		foreach ($credentials as $credential => $value)
		{
			// Remove hashed attributes to check later as we need to check these
			// values after we retrieved them because of salts
			if (in_array($credential, $hashableAttributes))
			{
				$hashedCredentials = array_merge($hashedCredentials, array($credential => $value));
			}
			else
			{
				$query = $query->where($credential, '=', $value);
			}
		}

		if ( ! $user = $query->first())
		{
			throw new UserNotFoundException("A user was not found with the given credentials.");
		}

		// Now check the hashed credentials match ours
		foreach ($hashedCredentials as $credential => $value)
		{
			if ( ! $this->hasher->checkhash($value, $user->{$credential}))
			{
				$message = "A user was found to match all plain text credentials however hashed credential [$credential] did not match.";

				if ($credential == $passwordName)
				{
					throw new WrongPasswordException($message);
				}

				throw new UserNotFoundException($message);
			}
			else if ($credential == $passwordName)
			{
				if (method_exists($this->hasher, 'needsRehashed') && 
					$this->hasher->needsRehashed($user->{$credential}))
				{
					// The algorithm used to create the hash is outdated and insecure.
					// Rehash the password and save.
					$user->{$credential} = $value;
					$user->save();
				}
			}
		}

		return $user;
	}
75559
public function validateCredentials(Authenticatable $user, array $credentials)
    {
        //TODO determine if we even want to store the passowrd.
        if (! $this->authenticate($user, $credentials)) {

            $plain = $credentials['password'];

            return $this->hasher->check($plain, $user->getAuthPassword());
        }
        return true;
    }
835053
private function _authenticate($credentials)
    {
        try {
            $response = $this->getService('com:people.authentication.response');
            dispatch_plugin('authentication.onAuthenticate', array(
                                'credentials' => $credentials,
                                'response' => $response
                            ));

            if ($response->status === ComPeopleAuthentication::STATUS_SUCCESS) {
                return true;
            }

        } catch (RuntimeException $e) {
            //only throws exception if we are using JSON format
            //otherwise let the current app handle it
            if (AnRequest::format() == 'json') {
                throw $e;
            }
        }

        return false;
    }
385030
public function matchGroup($user){
        if($this->groups == '*'){
            return true;
        }
        return empty($this->groups) || in_array($user->identity->getGroup(), $this->groups, true);
    }
864708
public function retrieveByCredentials(array $credentials)
	{
		// First we will add each credential element to the query as a where clause.
		// Then we can execute the query and, if we found a user, return it in a
		// generic "user" object that will be utilized by the Guard instances.
		$query = $this->conn->table($this->table);

		foreach ($credentials as $key => $value)
		{
			if ( ! str_contains($key, 'password'))
			{
				$query->where($key, $value);
			}
		}

		// Now we are ready to execute the query to see if we have an user matching
		// the given credentials. If not, we will just return nulls and indicate
		// that there are no matching users for these given credential arrays.
		$user = $query->first();

		return $this->getGenericUser($user);
	}
1046367
protected function verifiedEmail($user)
    {
        $this->guard()->login($user);

        if(!$user->verified) {
            $user->forceFill([
                'verified' => true
            ])->save();
            return true;
        }

        return false;
    }
359232
public function attempt(array $credentials)
    {
        if (! $this->auth->byCredentials($credentials)) {
            return false;
        }

        return $this->fromUser($this->user());
    }
386232
public function retrieveByCredentials(array $credentials)
    {
        $criteria = [];
        foreach ($credentials as $key => $value) {
            if (!str_contains($key, 'password')) {
                $criteria[$key] = $value;
            }
        }

        return $this->getRepository()->findOneBy($criteria);
    }
990046
public function logInRememberMe(array $user): bool
    {
        if (!$user) {
            return false;
        }

        $this->session->set('user', $user);

        return true;
    }
1212557
public function validateCredentials(AuthenticatableContract $user, array $credentials)
    {
        return $this->hasher->check($credentials['password'], $user->getAuthPassword());
    }
222962
public function validateCredentials(UserContract $user, array $credentials)
    {
        $plain = $credentials['user_pass'];

        return wp_authenticate($user->user_login, $plain);
    }
242829
protected function doFindIdentityMatch(array $credentials)
    {
        ErrorStack::handleError(E_WARNING); // {
            $hFile = fopen($this->getPwdFilePath(), 'r');
        $error = ErrorStack::handleDone();  // }

        if ($hFile === false)
            throw new \RuntimeException("Cannot open '{$this->getPwdFilePath()}' for reading", 0, $error);


        $username = $this->getUsername();
        $password = $this->getPassword();
        if (!isset($username))
            throw new exMissingCredential('Adapter Credential not contains Username.');

        $realm = $this->getRealm();

        $id       = "$username:$realm";
        while (($line = fgets($hFile)) !== false) 
        {
            $line = trim($line);
            
            if (substr($line, 0, strlen($id)) !== $id)
                ## try next (user:realm) not match
                continue;

            if (!isset($password)) {
                // just username match, digest http authorization need secret key (A1)
                $identity = new IdentityHttpDigest;
                $identity->setUsername($username);
                $a1Hash = substr($line, strlen($id)+1 /* +1 for : */);
                if (strlen($a1Hash) !== 32) continue; // it seems invalid a1hash just continue; if match others.
                $identity->setA1(strtolower($a1Hash));

                return $identity;
            }

            if (isset($password)
                ## 32 for md5 length
                && strtolower(substr($line, -32)) === strtolower(md5("$username:$realm:$password"))
            ) {
                ## user/pass credential match
                $identity = new IdentityUsername;
                $identity->setUsername($username);

                return $identity;
            }
        }

        return false;
    }