发送密码重置链接后如何设置重定向路径?
在ResetsPasswords trait中是这样的代码:
switch ($response) {
case Password::RESET_LINK_SENT:
return redirect()->back()->with('status', trans($response));
case Password::INVALID_USER:
return redirect()->back()->withErrors(['email' => trans($response)]);
}
但我不想更改供应商文件。还有别的办法吗?
最佳答案
您可以通过将 protected $redirectTo = '/dashboard';
添加到您的 PasswordController
来实现这一点。
所以你的 Controller 看起来像这样:
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
class PasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
*/
use ResetsPasswords;
protected $redirectTo = '/dashboard';
//The rest of the controller below this...
并且您可以通过将 /dashboard
更改为您希望将它们重定向到的位置来自定义路由。
您应该查看 docs了解更多信息。
关于php - 在 Laravel 5.1 中发送密码重置链接后重定向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32812590/