The password in {code...} is intended to be encrypted in a defined method.
Auth::attempt(array('username' => $username, 'password' => $password),false)
In this case, the password is intended to be encrypted using a defined method.
Reply content:
Auth::attempt(array('username' => $username, 'password' => $password),false)
In this case, the password is intended to be encrypted using a defined method.
The document is not written, but we can look at the source code.
The Auth method is implemented inIlluminate\Auth\GuardInside
/*** 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); // click here. // If N 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;}/*** Determine if the user matches the credentia Ls. ** @ param mixed $ user * @ param array $ credentials * @ return bool */protected function hasValidCredentials ($ user, $ credentials) {// execute the validCredentials method return for the authentication drive! Is_null ($ user) & $ this-> provider-> validateCredentials ($ user, $ credentials );}
By default, eloquent is used as the authentication drive.Illuminate\Auth\EloquentUserProviderImplementation
public function validateCredentials(UserContract $user, array $credentials) { $plain = $credentials['password']; return $this->hasher->check($plain, $user->getAuthPassword()); }
So if you want to change the verification logic, you can inherit the original drive and then rewrite the logic in 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 the boot () of AppServiceProvider.
Auth::setProvider(new TestUserProvider());
This document has been written! Don't be lazy and don't read the document. your most recent questions are written in the document.