I have created new project in Laravel 5.2 and tried to modify default behavior of Auth-Login.
Created new method called postLogin which is being called when login form is submitted.
Below is the code I have written to achieve login throttling in postRegister Method.
protected function postLogin(AuthLoginRequest $request){
$credentials = $this->getCredentials($request);
$credentials['is_activated'] = "Yes";
$remember = $request->has('remember');
$throttles = $this->isUsingThrottlesLoginsTrait();
if ($throttles && $this->hasTooManyLoginAttempts($request)) {
return $this->sendLockoutResponse($request);
}
if (Auth::guard($this->getGuard())->attempt($credentials, $remember)) {
// add login in case of success
return $this->handleUserWasAuthenticated($request, $throttles);
} else {
if ($throttles) {
$this->incrementLoginAttempts($request);
}
return redirect("/login")
->withInput($request->only('email', 'remember'))
->withErrors([
$this->loginUsername() => $this->getFailedLoginMessage(),
]);
}
}
While debugging, I found that $this->hasTooManyLoginAttempts($request) method never returns true.
Can someone please notify me what I am lacking in order to make this work?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire