【发布时间】:2016-06-01 15:34:13
【问题描述】:
我是 laravel 的新手,正在做一个示例项目作为学习目的。我使用以下命令创建了身份验证:
php artisan make:auth
我已经在 Authcontroller.php 中为所有成功的登录/注册提供了重定向链接:
protected $redirectTo = '/admin';
所有这些工作都很好,我的问题是当我尝试使用 laravel 5.2 内置身份验证控制器上的密码重置选项重置密码时,我可以用新密码重置我的旧密码。但是在重置我的密码后,它会被重定向到 examplelaravel.com/home 之类的链接。根据我在 Authcontroller.php 中给出的重定向链接(受保护的 $redirectTo = '/admin';),它不会进入 examplelaravel.com/admin。
在浏览我的 laravel 项目中的每个文件时,我看到了一个名为 vendor\laravel\framework\src\Illuminate\Foundation\Auth\RedirectsUsers.php 的文件,其中包含如下方法:
public function redirectPath()
{
if (property_exists($this, 'redirectPath')) {
return $this->redirectPath;
}
return property_exists($this, 'redirectTo') ? $this->redirectTo : '/home';
}
我已将上述文件中的 /home 更改为 /admin,并且我在成功重置密码后有关重定向的问题得到了修复。但我不知道这是否是正确的方法?像我上面那样编辑供应商文件夹中的文件是否正确?请帮我。提前致谢。
【问题讨论】:
-
按照你的说法,
PasswordController中的$redirectTo好像没有改。
标签: php laravel authentication url-redirection laravel-5.2