Retrieve a user by the given credentials.

@param  array  $credentials
@return \Illuminate\Auth\UserInterface|null
10693
public function retrieveByCredentials(array $credentials)
	{
		Kinvey::setAuthMode('admin');
		$result = parent::retrieveByCredentials($credentials);
		Kinvey::setAuthMode('app');

		return $result;
	}
1010605
private function processAuthentication(array $credentials)
    {
        /** @var \Ma27\ApiKeyAuthenticationBundle\Service\Auth\AuthenticationHandlerInterface $authenticationHandler */
        $authenticationHandler = $this->get('ma27_api_key_authentication.auth_handler');
        /** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher */
        $dispatcher = $this->get('event_dispatcher');

        try {
            $user = $authenticationHandler->authenticate($credentials);
        } catch (CredentialException $ex) {
            $userOrNull = $user ?? null;
            $dispatcher->dispatch(
                Ma27ApiKeyAuthenticationEvents::CREDENTIAL_EXCEPTION_THROWN,
                new OnCredentialExceptionThrownEvent($ex, $userOrNull)
            );

            return [$userOrNull, $ex];
        }

        return [$user, null];
    }
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();
    }
1203047
public function authentication(Request $request, array $credentials)
    {
        if (!isset($credentials['username'], $credentials['password'])) {
            return $request;
        }
        if (!isset($credentials['realm'])) {
            $credentials = $this->_getServerInfo($request, $credentials);
        }
        if (!isset($credentials['realm'])) {
            return $request;
        }
        $value = $this->_generateHeader($request, $credentials);

        return $request->withHeader('Authorization', $value);
    }
1299615
public function authenticate(array $credentials, $remember = false)
    {
        $user = $this->sentry->authenticate($credentials,$remember);
        $this->event->fire('users.login',array($user));
        return $user;
    }
491958
public function login(array $credentials, $remember = true)
    {
        $uniqueAlias = strpos($credentials['username'], '@') ? 'email' : 'username';
        $person = $this->getService('repos:people.person')->find(array(
            $uniqueAlias => $credentials['username'],
            'enabled' => 1
        ));

        if (is_null($person)) {
            $msg = "Did not find a user with username: ".$credentials['username'];
            throw new AnErrorException($msg, AnHttpResponse::UNAUTHORIZED);
        } else {
            $person->visited();
            $this->_createSession($person);

            $results = dispatch_plugin('user.onAfterLoginPerson', array('person' => $person));
            foreach ($results as $result) {
                if ($result instanceof Exception || $result === false) {
                    return false;
                }
            }
        }

        // create a remember cookie that contains the ecrypted username and password
        if ($remember) {
            $key = get_hash('AN_LOGIN_REMEMBER', 'md5');
            $crypt = $this->getService('anahita:encrypter', array('key' => $key, 'cipher' => 'AES-256-CBC'));
            $cookie = $crypt->encrypt(serialize(array(
                'username' => $credentials['username'],
                'password' => $credentials['password'],
            )));
            $oneYear = 365 * 24 * 3600;
            $hash = get_hash('AN_LOGIN_REMEMBER');
            setcookie($hash, $cookie, time() + $oneYear, '/');
        }

        return $person;
    }
508404
protected function validateEmailVerification(array $credentials)
    {
        if (is_null($user = $this->getUser($credentials))) {
            return static::INVALID_USER;
        }

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

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

        return $user;
    }
148555
public function authenticate(array $credentials)
    {

        // Dirty hack so we can use in both User->Authenticator->authenticate() and \Nette\Security\User->login() methods
        // arrays with named keys instead of anonymous arrays.
        // Eg. $userAuthenticator->authenticate(['username' => $username, 'alwaysLogin' => true]); instead of
        // $userAuthenticator->authenticate([$username, null, null, null, true]);
        if (count($credentials) == 1 && isset($credentials[0]) && is_array($credentials[0])) {
            $credentials = $credentials[0];
        }

        $user = false;
        $source = null;
        $regenerateToken = null;
        $exception = null;
        $authenticators = $this->authenticatorManager->getAuthenticators();
        /** @var AuthenticatorInterface $authenticator */
        foreach ($authenticators as $authenticator) {
            try {
                $u = $authenticator->setCredentials($credentials)->authenticate();

                $regenerateToken = $authenticator->shouldRegenerateToken();

                if ($u !== null && $u !== false) {
                    $user = $u;
                    $source = $authenticator->getSource();
                    break;
                }
            } catch (RateLimitException $e) {
                $exception = $e;
                break;
            } catch (AuthenticationException $e) {
                if ($exception === null) {
                    $exception = $e;
                }
                continue;
            }
        }

        if ($user === false && $exception !== null) {
            throw $exception;
        }
        if ($user === false) {
            throw new AuthenticationException('', UserAuthenticator::IDENTITY_NOT_FOUND);
        }
        $this->emitter->emit(new UserSignInEvent($user, $source, $regenerateToken ?? true));

        $arr = $user->toArray();
        unset($arr[self::COLUMN_PASSWORD_HASH]);

        $groups = [];
        if ($user['role'] === UsersRepository::ROLE_ADMIN) {
            $userGroups = $user->related('admin_user_groups');
            foreach ($userGroups as $userGroup) {
                $groups[] = $userGroup->admin_group->name;
            }
        }

        return new Identity($user['id'], $groups, $arr);
    }
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);
    }
984764
public function validate(array $credentials = [])
    {
        if (empty($credentials[$this->inputKey])) {
            return false;
        }

        $credentials = [$this->storageKey => $credentials[$this->inputKey]];

        if ($this->provider->retrieveByCredentials($credentials)) {
            return true;
        }

        return false;
    }
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);
    }
946592
public function setSnsCredentials(array $credentials = null)
    {
        ValidationUtility::ensureNullOrArrayOfType(
            '$credentials', $credentials, __NAMESPACE__ . '\SnsCredentials');

        $this->snsCredentials = $credentials;

        return $this;
    }
72414
protected function getLoginCredential($credentials = array())
	{
		$loginField = $this->app['config']['auth.credentials.login'];

		if (isset($credentials[$loginField]))
		{
			return $credentials[$loginField];
		}
		else if (Input::has($loginField))
		{
			return Input::get($loginField);
		}
		else if (isset($credentials['user_login']))
		{
			return $credentials['user_login'];
		}
		else if (isset($credentials['log']))
		{
			return $credentials['log'];
		}

		throw new InvalidArgumentException("Login field not found");

	}
1060137
public static function getSession($credentials)
    {
        $connectionData = new PagSeguroConnectionData($credentials, 'sessionService');

        $url = self::buildSessionURL($connectionData)  . "?" . $connectionData->getCredentialsUrlQuery();

        try {
            $connection = new PagSeguroHttpConnection();
            $connection->post(
                $url,
                array(),
                $connectionData->getServiceTimeout(),
                $connectionData->getCharset()
            );

            $httpStatus = new PagSeguroHttpStatus($connection->getStatus());

            switch ($httpStatus->getType()) {
                case 'OK':

                    $session = PagSeguroSessionParser::readResult($connection->getResponse());

                    return $session->getId();

                    LogPagSeguro::info(
                        "PagSeguroSessionService.getSession()(" . $session->toString() . ") - end {1}"
                    );
                    break;
                    case 'BAD_REQUEST':
                        $errors = PagSeguroSessionParser::readErrors($connection->getStatus());
                        $e = new PagSeguroServiceException($httpStatus, $errors);
                        LogPagSeguro::error(
                            "PagSeguroSessionService.getSession() - error " .
                            $e->getOneLineMessage()
                        );
                    throw $e;
                    break;
                    default:

                        $e = new PagSeguroServiceException($httpStatus);
                        LogPagSeguro::error(
                            "PagSeguroSessionService.getSession() - error " .
                            $e->getOneLineMessage()
                        );
                    throw $e;
                    break;
            }
        } catch (PagSeguroServiceException $e) {
            throw $e;
        } catch (Exception $e) {
            LogPagSeguro::error("Exception: " . $e->getMessage());
            throw $e;
        }
    }
1269387
public function getServerCredential($credential)
    {
        $credentials = $this->getServerCredentials();

        return isset($credentials[$credential]) ? $credentials[$credential] : null;
    }
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;
    }
757837
public static function handler(array $credentials = array()) {

		$calendar_guid = elgg_extract('calendar_guid', $credentials);
		$user_guid = elgg_extract('user_guid', $credentials);
		$token = elgg_extract('token', $credentials);

		$ia = elgg_set_ignore_access(true);
		$calendar = get_entity($calendar_guid);
		$user = get_entity($user_guid);
		elgg_set_ignore_access($ia);

		$pam = new PAM($calendar, $user);

		if (!has_access_to_entity($calendar, $user)) {
			throw new LoginException('User does not have access to this calendar');
		}

		if (!$calendar->getToken()) {
			throw new LoginException('Calendar does not allow remote access');
		}

		if (!$pam->validateToken($token)) {
			throw new LoginException('Invalid token');
		}

		return true;
	}