Laravel's Auth is used to log on via email by default. how can I change it to the user name OR email address to log on? How does one display the verification code for multiple logon errors? (This is the YII2 method) when logging on, you can log on with a user name or email address. if the user name or email address is incorrect three times, you must enter the verification code. how can this problem be solved? Laravel's Auth is used to log on via email by default. how can I change it to the user name OR email address to log on?
How does one display the verification code for multiple logon errors? (This is the YII2 method)
You can log on with a user name or email address. if the user name/email address or password is incorrect three times, you must enter the verification code. how can this problem be achieved?
Reply content:
Laravel's Auth is used to log on via email by default. how can I change it to the user name OR email address to log on?
How does one display the verification code for multiple logon errors? (This is the YII2 method)
You can log on with a user name or email address. if the user name/email address or password is incorrect three times, you must enter the verification code. how can this problem be achieved?
Rewrite the postLogin logon function:
/*** Handle a login request to the application. ** @ param \ Illuminate \ Http \ Request $ request * @ return \ Illuminate \ Http \ Response */public function postLogin (Request $ request) {// Obtain the form value $ username = $ request-> input ('Username'); $ password = $ request-> input ('password '); $ remeber = $ request-> input ('remember'); // determines whether the email address or user name logon $ type = filter_var ($ username, FILTER_VALIDATE_EMAIL )? 'Email ': 'username'; // login form verification $ validator = Validator: make ($ request-> all (), ['username' => 'bail | required | min: 5 | max: 30', 'password' => 'bail | required | min: 8 | max: 50',]); // if ($ validator-> fails () {$ errors = $ validator-> errors ()-> all (); if (count ($ errors)> 0) {Flash: error (implode ('
', $ Errors);} return redirect ('/login')-> withInput ();} // if ($ type = 'Email ') {if (Auth: attempt (['email '=> $ username, 'password' => $ password], $ request-> has ('Remember '))) {Flash ('logon successfully'); return redirect ()-> intended ($ this-> redirectPath () ;}} else if (Auth :: attempt (['username' => $ username, 'password' => $ password], $ request-> has ('remember '))) {Flash ('logon successfully'); return redirect ()-> intended ($ this-> redirectPath ();} else {Flash (Lang: get ('auth. failed '), 'error'); return redirect ('/login')-> withInput ();}}
The problem has not been completely solved, so it should be hung first.
After logging on to the client, click the count parameter and submit it to the server. if the request fails and the response value includes the number of next logins, the server records the session. In this way, the client requests the verification code three times asynchronously, and then enters the logon information. The number of logins parameter is included, and the server determines the number of logins. if the number of logins does not reach three, verification codes are not required to determine the opposite.