mardi 27 juin 2017

Laravel get number of failed login attempt

I am using Laravel 5.4 just trying to get the number of failed login attempt from controller as shown below.. It always returns 0 but hasTooManyLoginAttempts works fine. anyone has any ideas?

In LoginController.php

protected function hasTooManyLoginAttempts(Request $request)
{
    return $this->limiter()->tooManyAttempts(
        $this->throttleKey($request), 3, 1
    );
}

Above code works fine by locking user for 1 minute if there is failed login attempt of 3 times. But I want to get the count of login attempt.based on below code

public function tooManyAttempts($key, $maxAttempts, $decayMinutes = 1)
{

    echo $this->attempts($key);
    exit;

    if ($this->cache->has($key.':lockout')) {
        return true;
    }

    if ($this->attempts($key) > $maxAttempts) {
        $this->lockout($key, $decayMinutes);

        $this->resetAttempts($key);

        return true;
    }

    return false;
}

echo $this->attempts($key); always returns 0.how do we figure out this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire