/** * Attempt to create an AuthToken from user credentials. * * @param array $credentials * @return bool|AuthToken */ public function attempt(array $credentials) { $user = $this->users->retrieveByCredentials($credentials); if ($user instanceof Authenticatable && $this->users->validateCredentials($user, $credentials)) { return $this->create($user); } return false; }
/** * Get the user for the given credentials. * * @param array $credentials * @return \Illuminate\Contracts\Auth\CanResetPassword * * @throws \UnexpectedValueException */ 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; }
/** * Get the user for the given credentials. * * @param array $credentials * @return \Krucas\LaravelUserEmailVerification\Contracts\RequiresEmailVerification * * @throws \UnexpectedValueException */ public function getUser(array $credentials) { $credentials = Arr::except($credentials, ['token']); $user = $this->users->retrieveByCredentials($credentials); if ($user && !$user instanceof Contracts\RequiresEmailVerification) { throw new UnexpectedValueException('User must implement RequiresEmailVerification interface.'); } return $user; }
/** * Attempt to authenticate a user using the given credentials. * * @param array $credentials * @param bool $remember * @param bool $login * @return bool */ public function attempt(array $credentials = [], $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; }
public function retrieveByCredentials(array $credentials) { if ($this->isUsingProvider()) { // get the user from the provider $user = $this->provider->retrieveByCredentials($credentials); if ($user !== null || $this->userMustExistInProvider) { return $user; } } // get the name of the credentials username field $usernameField = $this->getCredentialsField('username'); // grab the username from the credentials passed $username = $usernameField !== null ? array_get($credentials, $usernameField) : null; if ($username !== null) { // get the user from LDAP return $this->ldapServer->retrieveByUsername($username); } }