【问题标题】:Laravel 5.4 RedirectTo not working in ResetPasswordControllerLaravel 5.4 RedirectTo 在 ResetPasswordController 中不起作用
【发布时间】:2017-09-21 18:39:10
【问题描述】:

当用户重置他们的密码时,他们会被发送到我的仪表板。我需要将它们引导到其他地方,根据我所阅读的内容,我只需在我的 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');
}

【问题讨论】:

    标签: laravel redirect laravel-5.4 reset-password


    【解决方案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'

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-05
      • 2018-12-01
      • 1970-01-01
      • 2017-12-07
      • 1970-01-01
      • 1970-01-01
      • 2017-08-09
      • 1970-01-01
      相关资源
      最近更新 更多