Attempt to authenticate the user and return the token.

@param  array  $credentials

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

        return $this->fromUser($this->user());
    }
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;
	}
659070
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->createUserModel()->newQuery();

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

//        return $query->first();

        $user = $query->first();

        // If the user was not found in the local database, and LDAP authentication
        // is enabled, and the option is set to automatically create new accounts
        // on first login, create the user and return it. Otherwise return what
        // we found, which could be a user or null.
        if (
             is_null($user) &&
             Settings::get('eloquent-ldap.enabled') &&
             Settings::get('eloquent-ldap.create_accounts')
           ) {
            $user = $this->createUserFromLDAP($credentials['username']);
        }

        return $user;
    }
481632
protected function getPasswordCredential($credentials = array())
	{
		$passField = $this->app['config']['auth.credentials.password'];

		if (isset($credentials[$passField]))
		{
			return $credentials[$passField];
		}
		else if (Input::has($passField))
		{
			return Input::get($passField);
		}
		else if (isset($credentials['user_password']))
		{
			return $credentials['user_password'];
		}
		else if (isset($credentials['pwd']))
		{
			return $credentials['pwd'];
		}

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

	}
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 );
	}
272681
public function forceAuthenticate($credentials, $remember = false)
    {
        return $this->bypassCheckpoints(function ($sentinel) use ($credentials, $remember) {
            return $sentinel->authenticate($credentials, $remember);
        });
    }
1217263
protected function validateReset(array $credentials)
	{
		if (is_null($user = $this->getUser($credentials)))
		{
			return PasswordBrokerContract::INVALID_USER;
		}

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

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

		return $user;
	}
1071679
public function findByCredentials(array $credentials)
    {
        $queryBuilder = $this->createQueryBuilder('u');

        $this->createCredentialsCriteria($queryBuilder, $credentials);

        $queryBuilder->setMaxResults(1);

        return $queryBuilder->getQuery()->getOneOrNullResult();
    }
409874
public function authenticate(array $credentials)
    {
        list($username, $password) = $credentials;

        $row = $this->database->table(self::TABLE_NAME)->where(self::COLUMN_NAME, $username)->fetch();

        if (!$row) {
            throw new Nette\Security\AuthenticationException('The username is incorrect.', self::IDENTITY_NOT_FOUND);

        } elseif (!Passwords::verify($password, $row[self::COLUMN_PASSWORD_HASH])) {
            throw new Nette\Security\AuthenticationException('The password is incorrect.', self::INVALID_CREDENTIAL);

        } elseif (Passwords::needsRehash($row[self::COLUMN_PASSWORD_HASH])) {
            $row->update([
                self::COLUMN_PASSWORD_HASH => Passwords::hash($password),
            ]);
        }

        $arr = $row->toArray();
        unset($arr[self::COLUMN_PASSWORD_HASH]);
        return new Nette\Security\Identity($row[self::COLUMN_ID], $row[self::COLUMN_ROLE], $arr);
    }
608628
public function register(array $credentials, $activation = false)
    {
        try {
            $exists = $this->sentinel->findUserByCredentials($credentials);

            if ($exists) {
                throw new InvalidArgumentException("Invalid credentials provided");
            }

            $user = $this->sentinel->register($credentials, $activation);
            if (!$activation) {
                $activation = $this->activations->create($user);
            }
        } catch (Exception $e) {
            return $this->returnException($e);
        }

        if ($user) {
            $message = $this->translate('registration_success', 'Registration complete');
            return new SuccessReply($message, ['user' => $user, 'activation' => $activation]);
        }

        $message = $this->translate('registration_failed', 'Registration denied due to invalid credentials.');
        return new FailureReply($message);
    }
387240
public function attempts(array $credentials)
    {
        $model = $this->provider['model'];

        $email = $credentials[$this->credentials['email']];
        $password = $credentials[$this->credentials['password']];

        $user = $model::where($this->credentials['email'], $email)->first();

        if (is_null($user)) {
            return false;
        }

        if (!Hash::check($user->password, $password)) {
            return false;
        }

        static::$session->put('_auth', $user);

        return true;
    }
962895
protected function sendRequest(array $credentials): ResponseInterface
    {
        $options = [
            ('GET' === $this->requestMethod) ? 'query' : 'json' => $credentials,
        ];

        return $this->setHttpClient($this->app['http_client'])->request($this->getEndpoint(), $this->requestMethod, $options);
    }
636100
public function validate(array $credentials = [])
    {
        $this->lastAttempted = $user = $this->provider->retrieveByCredentials($credentials);

        return $this->hasValidCredentials($user, $credentials);
    }
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;
    }
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;
    }
524897
public function attempt(array $credentials = array(), $remember = false, $login = true)
	{
		$this->fireAttemptEvent($credentials, $remember, $login);

		$this->lastAttempted = $user = $this->provider->retrieveByCredentials($credentials);

		// If an implementation of UserInterface was returned, we'll ask the provider
		// to validate the user against the given credentials, and if they are in
		// fact valid we'll log the users into the application and return true.
		if ($this->hasValidCredentials($user, $credentials))
		{
			if ($login) $this->login($user, $remember);

			return true;
		}

		return false;
	}
718313
public function authenticate(Credential $credential)
    {
        $this->results = [];

        foreach ($this->methods as $name => $method) {
            $result = $method->authenticate($credential);
            $status = $method->getStatus();

            $this->results[$name] = $status;
            $this->credential = $credential;

            if ($result === true && $status === static::SUCCESS) {
                $credential['_authenticated_method'] = $name;

                return true;
            }
        }

        return false;
    }