Attempt to find a UserInterface by given login credentials
returns the UserInterface or null on error

@param array $credentials
@return null|User
177875
public function findByAuth($provider, $identifier) {
        $user = null;

        $login = $this->repository->findByAuth($provider, $identifier);

        if($login !== null)
            $user = $login->getUser();

        return $user;
    }
669538
public function getUserLogin(UserServiceInterface $userService)
    {
        $user = $this->getAndLogUserByCookie($userService);
        return $user ? $user->getLogin() : null;
    }
1014202
private function connect(Credentials $credentials) : PDO
    {
        if ($this->pdo === null) {
            $this->pdo = new PDO($credentials->getDSN(), $credentials->getUsername(), $credentials->getPassword());
        }

        return $this->pdo;
    }
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;
    }
294320
public function validateCredentials(UserInterface $user, array $credentials)
	{
		if($user == NULL)
			return FALSE;
		if(isset($credentials['NTLM']))
			return TRUE;
		if($credentials['password'] == '')
			return FALSE;

		if(!$result = @ldap_bind($this->conn, $user->id, $credentials['password']))
			return FALSE;

		return TRUE;
	}
677976
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 = array();
        $coll = $this->conn->{$this->table};

        foreach ($credentials as $key => $value)
        {
            if ( ! str_contains($key, 'password'))
            {
                $query[$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 = $coll->findOne($query);

        if ( ! is_null($user))
        {
            return new MongolUser((array) $user);
        }
    }
352037
public function login($credentials) {
    if (!isset($credentials['login']) || !isset($credentials['password'])) {
      throw new IllegalArgumentException("The parameters 'login' and 'password' are required");
    }
    $config = ObjectFactory::getInstance('configuration');

    $login = $credentials['login'];
    $password = $credentials['password'];

    // try to receive the user with given credentials
    $user = $this->principalFactory->getUser($login, true);

    // check if user exists
    $loginOk = false;
    if ($user != null && $user->isActive()) {
      // check password
      $loginOk = $user->verifyPassword($password);
      if ($loginOk) {
        // load user config initially
        $userConfig = $user->getConfig();
        if (strlen($userConfig) > 0) {
          $config->addConfiguration($userConfig);
        }
        return $user;
      }
    }
    return null;
  }
1312484
public function loadUser(string $username): ?UserInterface
    {
        if (!isset($this->cache[$username])) {
            $this->cache[$username] = $this->user_provider->loadUserByUsername($username);
        }

        return $this->cache[$username] ?: null;
    }
334719
protected function findUser(OutputInterface $output, string $username): ?User
    {
        try {
            /** @var User $user */

            return $this->userManager->loadUserByUsername($username);
        } catch (UsernameNotFoundException $e) {
            $message = $this->translator->trans(
                'user.does_not_exists',
                ['%username%' => $username],
                'security'
            );
            $output->writeln("<error>{$message}</error>");

            return null;
        }
    }
362222
public function checkCredentials($credentials, UserInterface $user)
    {
        return $this->userPasswordEncoderFactory->isPasswordValid($user, $credentials->getPassword());
    }
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();
	}
682423
public function getUser(array $credentials)
    {
        $credentials = Arr::except($credentials, ['token']);

        $user = $this->users->retrieveByCredentials($credentials);

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

        return $user;
    }
1080996
public function findIdentityByAuthClient(ClientInterface $client)
    {
        $remote = $this->getRemoteUser($client);
        if (!$remote->provider) {
            return null;
        }
        if ($remote->client_id) {
            return $this->findIdentity($remote->client_id);
        }
        $email = $client->getUserAttributes()['email'];
        $user = $this->findIdentityByEmail($email);
        if (!$user) {
            return null;
        }
        if ($remote->isTrustedEmail($email)) {
            return $this->setRemoteUser($client, $user);
        }

        return null;
    }
436744
protected function hasValidCredentials($user, $credentials)
    {
        return ! is_null($user) && $this->provider->validateCredentials($user, $credentials);
    }
955984
public function retrieveByCredentials(array $credentials): ?UserContract
    {
        $name = Authen::getIdentifierName();

        if (! isset($credentials[$name]) || empty($credentials[$name])) {
            return parent::retrieveByCredentials($credentials);
        }

        $identifier = $credentials[$name];
        unset($credentials[$name]);

        // 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->createModel()
                    ->newQuery()
                    ->findByIdentifiers($identifier);

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

        return $query->first();
    }
1356712
public function authenticate(array $credentials): Identity
	{
		list($username, $password) = $credentials;

		$user = $this->orm->users->getByUsername($username);

		if (!$user) {
			throw new AuthenticationException('The username is incorrect.', self::IDENTITY_NOT_FOUND);
		} elseif (!Passwords::verify($password, $user->password)) {
			throw new AuthenticationException('The password is incorrect.', self::INVALID_CREDENTIAL);
		} elseif (!$user->active) {
			throw new AuthenticationException('Account is deactivated.', self::NOT_APPROVED);
		} elseif (Passwords::needsRehash($user->password)) {
			$user->setPassword($password);
			$this->orm->persistAndFlush($user);
		}

		return new Identity($user->id);
	}
154306
protected function getUserEntity($userName)
    {
        if (!$userEntity = $this->getRepositoryUsers()->getUser($userName)) {
            $this->flashLogger->error(Trans::__('general.phrase.error-user-name-password-incorrect'));

            return null;
        }

        if (!$userEntity->getEnabled()) {
            $this->systemLogger->alert("Attempt to login with disabled account by '$userName'", ['event' => 'security']);
            $this->flashLogger->error(Trans::__('general.phrase.login-account-disabled'));

            return null;
        }

        return $userEntity;
    }