mercredi 9 septembre 2020

Laravel custom Login Throttling

I want to add Login Throttling to my custom login code. I use an email and a password for the login. Here is what i did: I added

    use ThrottlesLogins; 
    protected $maxLoginAttempts=3;
    protected $lockoutTime=20; 

at the beginning of my class, and then in my login method i did:

    public function login(Request $request)
    {
        if ($this->hasTooManyLoginAttempts($request)) {
            $this->fireLockoutEvent($request);
            return $this->sendLockoutResponse($request);
        }

If the login fails i add

$this->incrementLoginAttempts($request);

if it succeed I add

$this->clearLoginAttempts($request);

The problem though i'm getting:

Undefined method LoginController::username

I'm guessing it is because i use an email instead of a username for login. What is the solution for this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire