I'm using Laravel 5.0 built-in authentication controllers, and in the AuthController I have 2 variables:
protected $redirectTo = '/';
protected $redirectAfterLogout = '/';
Is there any variable which would redirect to a specific page if and only if the login failed? If not, how should I do it?
答案 0 :(得分:-1)
请在控制器中插入波纹管方法
public function authenticate(Request $request)
{
if (Auth::attempt(['email' => $request->input('email'), 'password' => $request->input('password')]))
{
return redirect()->intended('dashboard');
} else {
return redirect('your-path-to-redirect');
}
}
答案 1 :(得分:-1)
我知道这个问题已经过时但我会发表我的答案,因为它对将来的某些人有用。
当身份验证失败时,默认情况下会将其重定向到 / auth / login URI。如果你想修改它,只需在AuthController上添加 loginPath属性并设置你自己的路径:
protected $loginPath = '/your-path';
您可以在Authentication Laravel Docs
中找到更多信息希望这有帮助!