Php Laravel Auth隐藏重定向
安装新的Laravel 5.4项目 运行php artisan make:auth 转到(未登录) 我被重定向到 这个重定向看起来很神奇。这是回家的路线:Php Laravel Auth隐藏重定向,php,laravel,laravel-5,Php,Laravel,Laravel 5,安装新的Laravel 5.4项目 运行php artisan make:auth 转到(未登录) 我被重定向到 这个重定向看起来很神奇。这是回家的路线: || GET|HEAD |home||App\Http\Controllers\HomeController@index|web,auth| 我们永远不会使用index()方法,因为auth中间件需要 结束我打开auth中间件文件illumb\auth\middleware\Authenticate.php,没有提到/login重定向 从/
|| GET|HEAD |home||App\Http\Controllers\HomeController@index|web,auth|
我们永远不会使用index()
方法,因为auth
中间件需要
结束我打开auth
中间件文件illumb\auth\middleware\Authenticate.php
,没有提到/login
重定向
从
/home
到/login
的重定向在哪里定义?检查app/Exceptions/Handler.php
文件,您将看到未经身份验证的用户的异常处理程序
:
protected function unauthenticated($request, AuthenticationException $exception)
{
if ($request->expectsJson()) {
return response()->json(['error' => 'Unauthenticated.'], 401);
}
return redirect()->guest(route('login'));
}
另外,重定向到home
您可以在app/Http/Middleware/RedirectIfAuthenticated.php
文件中看到
UPD1:登录/注册后重定向到主页,您可以在app/Http/Controllers/Auth/LoginController.php
和app/Http/Controllers/Auth/RegisterController.php
中进行设置。
看起来像
protected $redirectTo = '/home';