Laravel 5.4 RedirectTo不能在ResetPasswordController中工作

时间:2017-04-24 22:58:17

标签: laravel redirect laravel-5.4 reset-password

当用户重置密码时,会将其发送到我的信息中心。我需要将它们引导到其他地方并从我读过的内容中简单地在我的ResetPasswordController中添加RedirectTo,但这样做没有效果:

namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
class ResetPasswordController extends Controller
{
   use ResetsPasswords;

   protected $redirectTo = '/checkcart';

  public function __construct()
  {
     $this->middleware('guest');
  }
}

更新以提供有关默认身份验证路由的路由的信息

检查购物车路线:

Route::get('checkcart', 'CartController@checkcart');

密码重置路由由

决定
Route::auth();

具有默认值:

public function auth()
    {
    // Authentication Routes...
    $this->get('login', 'Auth\LoginController@showLoginForm')->name('login');
    $this->post('login', 'Auth\LoginController@login');
    $this->post('logout', 'Auth\LoginController@logout')->name('logout');

    // Registration Routes...
    $this->get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
    $this->post('register', 'Auth\RegisterController@register');

    // Password Reset Routes...
    $this->get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
    $this->post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
    $this->get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
    $this->post('password/reset', 'Auth\ResetPasswordController@reset');
}

1 个答案:

答案 0 :(得分:1)

use AuthenticatesUsers;

/**
 * Where to redirect users after login.
 *
 * @var string
 */
protected $redirectTo = '/home';

/**
 * Create a new controller instance.
 *
 * @return void
 */
public function __construct()
{
    $this->middleware('guest', ['except' => 'logout']);
}

这是默认代码,您只需更改" $ redirectTo =' / home'到你想要的路线 - " $ redirectTo =' / checkcart'

我将需要更多信息,例如如何定义路线以检测问题(如果尚未解决)