How should i redirect user to login page after a failed login? i tried in AuthController
:
protected $redirectTo ='/login';
protected $loginView = 'auth.login_register_form';
protected $loginPath = '/login';
but user does not redirected to /login
page , he get redirected back to the page he was in before
of curse there is a method in AuthenticateUser.php
that serve as login fails method:
protected function sendFailedLoginResponse(Request $request)
{
return redirect()->back()
->withInput($request->only($this->loginUsername(), 'remember'))
->withErrors([
$this->loginUsername() => $this->getFailedLoginMessage(),
]);
}
but i'm not allowed to edit this method . this is one of laravel core files.
In your controller you have to return him redirect (not just assign path to variable), for example
return redirect('/login');
If it's form with filled inputs you can do something like
return redirect('/login')->withInput();
In your example
protected function sendFailedLoginResponse(Request $request)
{
return redirect('/login')
->withInput($request->only($this->loginUsername(), 'remember'))
->withErrors([
$this->loginUsername() => $this->getFailedLoginMessage(),
]);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.