Lock Particular USer 24 hours if multiple login attempts

629 Views Asked by At

Wanted to Lock Particular User if he Trying for multiple Login Attempts. How to lock User Id , IP address for any Specific Controller?

Laravel Passport Token for Generation

if ($this->hasTooManyLoginAttempts($request)) {
    $this->fireLockoutEvent($request);
    return $this->sendLockoutResponse($request);
}
if ($this->attemptLogin($request)) {
    return $this->sendLoginResponse($request);
}


$this->incrementLoginAttempts($request);

return $this->sendFailedLoginResponse($request);

Wanted use above code for Locking User

1

There are 1 best solutions below

0
mdexp On BEST ANSWER

To customize the number of attempts and cooldown period you have to edit the middleware assigned to the api group.

To do so open up app/Http/Kernel.php and edit the throttle:60,1 line. Keep in mind that 60,1 means that the lockout will be fired after 60 failed attempts in one minute.

The last thing you have to be sure is to wrap your login route in the api middleware to apply the throttle one to your route.