laravel5.3 Auth middleware authentication failed after the jump address

Source: Internet
Author: User

In laravel5.3, auth middleware directly in the illuminate, and then if the user does not log in, it executes

His default jump is/login address I want to change the jump address to/user/login

5.2 Words can also understand 5.3 what kind of an implementation of this side?

Reply content:

In laravel5.3, auth middleware directly in the illuminate, and then if the user does not log in, it executes

His default jump is/login address I want to change the jump address to/user/login

5.2 Words can also understand 5.3 what kind of an implementation of this side?

This need to modify the app\exceptions\handler.php file, at the bottom there is a unauthenticaticated method

/** * Convert an authentication exception into an unauthenticated response. * * @param  \Illuminate\Http\Request  $request * @param  \Illuminate\Auth\AuthenticationException  $exception * @return \Illuminate\Http\Response */protected function unauthenticated($request, AuthenticationException $exception){    if ($request->expectsJson()) {        return response()->json(['error' => 'Unauthenticated.'], 401);    }    // 这里的login修改为user/login    return redirect()->guest('login');}

Custom redirect?

return redirect()->route('user.login');
  • 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.