Laravel5 logs on with the user name or email address. how does one display the verification code multiple times when a logon error occurs?

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.