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');