Laravel中设置登录成功及失败时重定向URI

WBOY
Release: 2016-06-23 13:18:34
Original
1402 people have browsed it

在Laravel中,如果使用自带的认证系统,登录成功后默认是跳转到 /home的,如果你想改变这个重定向 URI,可以在  AuthController中添加一个属性来实现:

protected $redirectPath = '/where/you/want';
Copy after login

此外,如果登录失败的话,会默认重定向到 /auth/login,这个重定向 RUI 也可以通过向 AuthController中添加一个属性来更改:

protected $loginPath = '/login';
Copy after login

Note:loginPath 属性只会改变用户登录失败时的重定向 URI ,而不会改变用户访问受保护的路由时重定向 URI(比如用户未登录状态下访问个人的设置中心)。该路径是在 App\Http\Middleware\Authenticate的 handle()方法中定义的,你需要到该文件中修改才可以。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!