Auth::attempt(array('username' => $username, 'password' => $password),false)
Password in this thing is trying to encrypt it in a way that you define.
Reply content:
Auth::attempt(array('username' => $username, 'password' => $password),false)
Password in this thing is trying to encrypt it in a way that you define.
The document did not write, but we can look at the source code
The implementation of the Auth method is Illuminate\Auth\Guard inside
/** * 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->fireattempteven T ($credentials, $remember, $login); $this->lastattempted = $user = $this->provider->retrievebycredentials ($credentials); See here//If An implementation of UserInterface is returned, we ' ll ask the provider//to validate the user Against the given credentials, and if they is in//fact valid we ' ll log the users into the application and retur n True. if ($this->hasvalidcredentials ($user, $credentials)) {if ($login) {$this->login ($user, $ Remember); } return true; } return false; }/** * Determine if the user matches the Credentials. * * @param mixed $user * @param array $credentials * @return bool */protected function Hasvalidcre Dentials ($user, $credentials) {//Validcredentials method to perform authentication drive return! Is_null ($user) && $this-&G T;provider->validatecredentials ($user, $credentials); }
The default is to use eloquent as the authentication drive, so look Illuminate\Auth\EloquentUserProvider inside the implementation
public function validateCredentials(UserContract $user, array $credentials) { $plain = $credentials['password']; return $this->hasher->check($plain, $user->getAuthPassword()); }
So if you want to change the logic of validation, you can inherit the original drive and rewrite the logic inside the validatecredentials.
class TestUserProvider extend EloquentUserProvider{ public function validateCredentials(UserContract $user, array $credentials) { $plain = $credentials['password']; return md5($plain) == $user->getAuthPassword(); }}
Finally set the drive, it is recommended to load Appserviceprovider boot () inside
Auth::setProvider(new TestUserProvider());
It's written in the document! Don't be lazy and don't read the documentation, the questions you've recently raised are written in the documentation.