2017-02-14 239 views
0

登录失败后,我应该如何将用户重定向到登录页面? 我试图在AuthControllerLaravel 5.2:将用户重定向到登录页面失败后

protected $redirectTo ='/login'; 
protected $loginView = 'auth.login_register_form'; 
protected $loginPath = '/login'; 

,但用户不重定向到/login页,他被重定向回他是在
诅咒之前存在AuthenticateUser.php充当登录的方法在网页失败的方法:

protected function sendFailedLoginResponse(Request $request) 
{ 
    return redirect()->back() 
     ->withInput($request->only($this->loginUsername(), 'remember')) 
     ->withErrors([ 
      $this->loginUsername() => $this->getFailedLoginMessage(), 
     ]); 
} 

,但我不能编辑此方法。这是laravel核心文件之一。

回答

1

在你的控制器,你必须回到他重定向(不仅仅是分配路径变量),例如

return redirect('/login'); 

如果是用实心输入形式,你可以这样做

return redirect('/login')->withInput(); 

在你的例子

protected function sendFailedLoginResponse(Request $request) 
{ 
    return redirect('/login') 
     ->withInput($request->only($this->loginUsername(), 'remember')) 
     ->withErrors([ 
      $this->loginUsername() => $this->getFailedLoginMessage(), 
     ]); 
} 
+0

你在说“AuthController”吗? – alex

+0

是的,如果你的验证失败添加重定向到你想要的页面 – KuKeC

+0

谢谢,所以你的意思是没有财产去做成功登录或注销的工作。我应该自己写这个方法 – alex

相关问题