Last active
September 23, 2016 02:11
-
-
Save Sarav-S/758565796804f0cdda7c90eceb674d29 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 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; | |
} | |
// If the authentication attempt fails we will fire an event so that the user | |
// may be notified of any suspicious attempts to access their account from | |
// an unrecognized user. A developer may listen to this event as needed. | |
if ($login) { | |
$this->fireFailedEvent($user, $credentials); | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment