除用户单击“重置密码”外,我要在用户登录时将其重定向到上一个URL。因此,如果用户单击重设密码然后尝试登录,则不应重定向回重设密码页面。到目前为止,当用户单击重置密码然后尝试登录时,我收到此错误The GET method is not supported for this route. Supported methods: POST.
。如何重定向到其他网址(如(reset-password))以外的以前的网址?
我已经尝试过session(['link' => url()->previous()])->except('password-reset');
,但遇到了错误Call to a member function except() on null
LoginController
public function showLoginForm()
{
session(['link' => url()->previous()]);
return view('auth.login');
}
路线
Route::post('password-reset', 'Auth\ForgotPasswordController@sendPasswordResetToken')->name('password.reset');
答案 0 :(得分:0)
$reset_route = route('password.reset');
$previous = url()->previous();
if(substr($previous, 0, strlen($reset_route)) !== $reset_route) {
session(['link' => url()->previous()]);
}
else {
session(['link' => route('other.route')]);
}