Laravel 5 log in as user name or mailbox, login errors show the captcha multiple times.

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

  • 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.