Retrieve a user by the given credentials.

@param  array $credentials
@return \Illuminate\Contracts\Auth\Authenticatable|\Illuminate\Database\Eloquent\Builder|User|null
962614
public function getByCredentials(array $credentials) : ?Authenticatable
    {
        if (empty($credentials)) {
            return null;
        }

        // 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
        // Eloquent User "model" that will be utilized by the Guard instances.
        $query = $this->getModel()->newQuery();

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

        return $query->first();
    }
516224
public function authenticate(string $credential, string $password = null): ?UserInterface
    {
        $user = $this->users->read($credential);

        if ($user) {
            if ($password && !$this->verifyPassword($user, $password)) {
                return null;
            }

            return ($this->userFactory)(
                $this->users->getIdentifier(),
                $this->getRoles($credential),
                $this->getDetails($user)
            );
        }

        return null;
    }
581177
public function retrieveByCredentials( array $credentials )
	{
		if ( empty( $credentials ) )
			return null;

		// 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
		// Eloquent User "model" that will be utilized by the Guard instances.
		$query = $this->createUsrModel()->newQuery();

		foreach ( $credentials as $key => $value )
			if ( !Str::contains( $key, 'password' ) )
				$query->where( $key, $value );

		return $query->first();
	}
947808
public function retrieveByCredentials(array $credentials)
    {
        $criteria = [];
        foreach ($credentials as $key => $value) {
            if (!Str::contains($key, 'password')) {
                $criteria[$key] = $value;
            }
        }

        return $this->getRepository()->findOneBy($criteria);
    }
113466
public function retrieveByCredentials(array $credentials)
    {
        $query = $this->query;
        $user_class = \Config::get('auth.model');

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

        return $query->findOne();
    }
589676
public function validateCredentials(UserContract $user, array $credentials)
    {

        $password = $credentials['password'];
        $username = array_key_exists('username', $credentials) ? $credentials['username'] : $this->model->whereEmail($credentials['email'])->FirstOrFail()->username;

        return $this->hasher->check(compact('username', 'password'), $user->getAuthPassword());
    }
118685
public function getUser(array $credentials)
    {
        $credentials = array_except($credentials, ['token']);
        $user = $this->users->retrieveByCredentials($credentials);
        if ($user && !$user instanceof CanResetPasswordContract) {
            throw new UnexpectedValueException(ucfirst($this->type).' must implement CanResetPassword interface.');
        }
        return $user;
    }
113835
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;
		$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);
			}
		}
		$user = $query->find();

		if ( ! $user->loaded() )
		{
			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);
			}
		}

		return $user;
	}
900276
public function authenticate(array $credentials)
    {
        list($username, $password) = $credentials;
        $user = $this->users->findOneBy(array('username' => $username));

        if (!$user) {
            throw new NS\AuthenticationException("User not found.", self::IDENTITY_NOT_FOUND);
        }

        if ($user->password !== $this->calculateHash($password)) {
            throw new NS\AuthenticationException("Invalid password.", self::INVALID_CREDENTIAL);
        }

        $permissions = array();
        foreach ($user->getRole()->getPermissions() as $key => $per) {
            $permissions[$per->getResource()] = $per->getRead();
        }

        return new NS\Identity($user->id, $user->getRole()->getName(), array(
            'username' => $user->username,
            'email' => $user->email,
            'permissions' => $permissions,
        ));
    }
362222
public function checkCredentials($credentials, UserInterface $user)
    {
        return $this->userPasswordEncoderFactory->isPasswordValid($user, $credentials->getPassword());
    }
1178888
public function getUser(array $credentials)
    {
        $user = $this->users->retrieveByCredentials(Arr::only($credentials, ['email']));

        if ($user && ! $user instanceof CanVerifyEmailContract) {
            throw new UnexpectedValueException('User must implement CanVerifyEmailContract interface.');
        }

        return $user;
    }
100646
protected function _getUser($profile)
    {
        $user = null;

        if ($profile->get('user_id')) {
            $userPkField = $this->_userModel->aliasField((string)$this->_userModel->getPrimaryKey());

            $user = $this->_userModel->find()
                ->where([
                    $userPkField => $profile->get('user_id'),
                ])
                ->find($this->getConfig('finder'))
                ->first();
        }

        if (!$user) {
            if ($profile->get('user_id')) {
                $this->_error = 'finder_failure';

                return null;
            }

            $user = $this->_getUserEntity($profile);
            $profile->set('user_id', $user->id);
        }

        if ($profile->isDirty()) {
            $this->_saveProfile($profile);
        }

        $user->set('social_profile', $profile);
        $user->unsetProperty($this->getConfig('fields.password'));

        return $user;
    }
634652
protected function getBitbucketAccessToken(array $credentials)
    {
        if (isset($this->bitbucketAccessTokens[$credentials['key']])) {
            return $this->bitbucketAccessTokens[$credentials['key']];
        }
        $result = $this->api()
            ->getHttpClient()
            ->post('https://bitbucket.org/site/oauth2/access_token', [
                'auth' => [$credentials['key'], $credentials['secret']],
                'body' => [
                    'grant_type' => 'client_credentials',
                ],
            ]);

        $data = $result->json();
        if (!isset($data['access_token'])) {
            throw new \RuntimeException('Access token not found in Bitbucket response');
        }

        $this->bitbucketAccessTokens[$credentials['key']] = $data['access_token'];

        return $data['access_token'];
    }
940011
public function retrieveByCredentials(array $credentials)
	{
		$result = ldap_search($this->conn, $this->config['basedn'], "(samaccountname={$credentials['username']})", $this->config['attributes']);
		if ($result === FALSE)
			return NULL;

		$entries = ldap_get_entries($this->conn, $result);
		if ($entries['count'] == 0 || $entries['count'] > 1)
			return NULL;

		return $this->clean($entries[0]);
	}
775268
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.
		$acct = $query->first();

		return $this->getGenericAccount( $acct );
	}
1267708
public function create(array $credentials)
	{
		if ( ! isset($credentials['permissions']) )
		{
			$credentials['permissions'] = array();
		}

		$user = $this->createModel();
		$user->values($credentials);
		$user->save();

		return $user;
	}
181056
public function setCredentials(array $credentials) : AuthenticatorInterface
    {
        if (array_key_exists('source', $credentials) && preg_match('/^api*/', $credentials['source'])) {
            $this->api = true;
            $this->source = $credentials['source'];
        }

        return $this;
    }