Laravel Auth By default is the mailbox to log in, how to change the user name or mailbox login?
Multiple login error display verification code and how to implement? (This is the way of YII2)
Login can be logged in the user name or mailbox, when the user name/mailbox or password Error 3 times after the request to enter a verification code, how to achieve?
Reply content:
Laravel Auth By default is the mailbox to log in, how to change the user name or mailbox login?
Multiple login error display verification code and how to implement? (This is the way of YII2)
Login can be logged in the user name or mailbox, when the user name/mailbox or password Error 3 times after the request to enter a verification code, how to achieve?
To override the Postlogin login function:
/** * Handle A login request to the application. * * @param \illuminate\http\request $request * @return \illuminate\http\response */public function postlogin (Request $re Quest) {//Get the value of the form $username = $request->input (' username '); $password = $request->input (' password '); $remeber = $request->input (' remember '); Determine if a mailbox or user name is logged in $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 ',]); Form validation failure Prompt if ($validator->fails ()) {$errors = $validator->errors ()->all (); if (count ($errors) > 0) {flash::error (' implode ('
', $errors)); } return redirect ('/login ')->withinput (); }//Login to verify if ($type = = ' email ') {if (auth::attempt (' email ' = $username, ' password ' + $password], $re Quest->has (' remember ')) {Flash (' login successful '); Return Redirect ()->intended ($this->redirectpath ()); }} else if (auth::attempt ([' username ' = = $username, ' password ' = ' = $password], $request->has (' Remember '))) { Flash (' login successful '); Return Redirect ()->intended ($this->redirectpath ()); } else {Flash (lang::get (' auth.failed '), ' error '); Return redirect ('/login ')->withinput (); }}
The problem is not completely solved, so hang up first.
After the client login, the click parameter is submitted to the server, it is unsuccessful and responds with the value of the next login number to the customer service side, which records the session. And so on up to 3 times the customer Service side direct asynchronous request pull verification code, and then fill in the login. With the number of login parameters, the server to determine the number of times, if not reached 3 does not need to verify the code to determine the contrary.