Retrieve a user by the given credentials.

@param  array $credentials
@return Account|null
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 );
	}
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;
    }
371813
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
        // Eloquent User "model" that will be utilized by the Guard instances.
        $query = $this->createModel()->newQuery();

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

        return $query->first();
    }
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);
	}
889760
public function getUser($credentials, UserProviderInterface $userProvider)
    {
        if (isset($credentials[$this->username_attribute])) {
            return $userProvider->loadUserByUsername($credentials[$this->username_attribute]);
        } else {
            return null;
        }
    }
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);
    }
1299615
public function authenticate(array $credentials, $remember = false)
    {
        $user = $this->sentry->authenticate($credentials,$remember);
        $this->event->fire('users.login',array($user));
        return $user;
    }
963175
public function tokenize(array $credentials)
    {
        if (empty($credentials)) {
            throw new AuthenticationException('Unable to create token, no or empty credentials');
        }

        foreach ($this->providers as $provider) {
            if (!$provider->supportsCredentials($credentials)) {
                continue;
            }

            if (!$token = $provider->tokenize($credentials)) {
                $this->stash()
                     ->destroy();

                throw new AuthenticationException(sprintf('Unable to create token, credentials could not be authenticated in provider "%s"', get_class($provider)));
            }

            $this->stash()
                 ->put($token);

            return $this;
        }

        $this->stash()
             ->destroy();

        throw new AuthenticationException(sprintf('Unable to create token, missing provider supporting credentials "%s"', implode(', ', array_keys($credentials))));
    }
636100
public function validate(array $credentials = [])
    {
        $this->lastAttempted = $user = $this->provider->retrieveByCredentials($credentials);

        return $this->hasValidCredentials($user, $credentials);
    }
275024
public function getAccountByProvider($provider)
    {
        $accounts = $this->getAccounts();
        return isset($accounts[$provider])
            ? $accounts[$provider]
            : null;
    }
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;
    }
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();
    }
125083
public function getByAttributes(array $attributes) : ?Model
    {
        if (empty($attributes)) {
            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 ($attributes as $key => $value) {
            $query->where($key, $value);
        }

        return $query->first();
    }
669732
public function retrieveByCredentials(array $credentials)
    {
        if (empty($credentials) ||
           (count($credentials) === 1 &&
            array_key_exists('password', $credentials))) {
            return;
        }

        // 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')) {
                continue;
            }

            if (is_array($value) || $value instanceof Arrayable) {
                $query->whereIn($key, $value);
            } else {
                $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);
    }
1272339
public function connect(array $credentials): \PDO
    {
        $dsn = 'mysql:';
        $dsnParams = [];
        $pdoOptions = [];
        if (!empty($credentials['host'])) {
            array_push($dsnParams, 'host='.$credentials['host']);
        }
        if (!empty($credentials['port'])) {
            array_push($dsnParams, 'port=' . $credentials['port']);
        }
        if (!empty($credentials['database'])) {
            array_push($dsnParams, 'dbname=' . $credentials['database']);
        }
        if (!empty($credentials['charset'])) {
            array_push($dsnParams, 'charset=' . $credentials['charset']);
        }
        $dsn .= implode(';', $dsnParams);

        if (!empty($credentials['timezone'])) {
            $tzOffset = $this->getMysqlTimeZoneOffset($credentials['timezone']);
            $pdoOptions = [
                \PDO::MYSQL_ATTR_INIT_COMMAND => "SET time_zone = '" . $tzOffset . "'"
            ];
        }

        try {
            $username = $credentials['username'] ?? '';
            $password = $credentials['password'] ?? '';
            $pdo = new \PDO($dsn, $username, $password, $pdoOptions);
            $pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
            return $pdo;
        } catch (\PDOException $e) {
            throw new DatabaseException(sprintf('Error connecting to database (%s)', $e->getMessage()));
        }
    }
1152745
protected function validateVerification(array $credentials)
    {
        if (is_null($user = $this->getUser($credentials))) {
            return Contracts\VerificationBroker::INVALID_USER;
        }

        if (!$this->tokens->exists($user, $credentials['token'])) {
            return Contracts\VerificationBroker::INVALID_TOKEN;
        }

        return $user;
    }
490076
public function getCredentialObject($accountId = null)
    {
        if ($accountId == null && array_key_exists($this->defaultAccountName, $this->credentialHashmap)) {
            $credObj = $this->credentialHashmap[$this->defaultAccountName];
        } elseif (array_key_exists($accountId, $this->credentialHashmap)) {
            $credObj = $this->credentialHashmap[$accountId];
        }

        if (empty($credObj)) {
            throw new InvalidCredentialException("Credential not found for " . ($accountId ? $accountId : " default user") .
                ". Please make sure your configuration/APIContext has credential information");
        }
        return $credObj;
    }