2017-03-10 21:48
浏览 91

Laravel Auth隐藏重定向

Install new Laravel 5.4 project.

Run php artisan make:auth.

Go to http://localhost:8000/home (without being logged in).

I get redirected to http://localhost:8000/login

This redirect seems like magic. This is the route for home:

|| GET|HEAD |home||App\Http\Controllers\HomeController@index|web,auth|

We never get to the index() method because the auth middleware takes over. I open the auth middleware file Illuminate\Auth\Middleware\Authenticate.php and there's no mention of the /login redirect.

Where is the redirect from /home to /login defined?

图片转代码服务由CSDN问答提供 功能建议

安装新的Laravel 5.4项目。</ p>

运行 php artisan make :AUTH </代码>。 </ p>

转到 http:// localhost:8000 / home (不 登录)。</ p>

我被重定向到 http:// localhost:8000 / 登录 </ p>

此重定向似乎很神奇。 这是回家路线:</ p>

  ||  GET | HEAD | home || App \ Http \ Controllers \ HomeController @index | web,auth | 
 </ code> </ pre> 

我们永远无法访问 index()< / code>方法,因为 auth </ code>中间件需要 over。 我打开 auth </ code>中间件文件 Illuminate \ Auth \ Middleware \ Authenticate.php </ code>,并且没有提及 / login </ code>重定向。</ p>

/ home </ code>重定向到 / login </ code>的位置在哪里?</ p> </ div>

1条回答 默认 最新

相关推荐 更多相似问题