mardi 27 décembre 2016

Why ThrottleLogin class increase attempts twice every time?

Problem

When i type wrong username and password, it show total attempts left. But due to some reasons, it increase 2 attempts every time. My code is below. Am I missing something?

Route

Route::post('/AuthenticateUser', 
    array(
        'uses'          =>  'API\Auth\apiLoginController@AuthenticateUser', 
        'as'            =>  'AuthenticateUser',
        'middleware'    =>  ['throttle: 6,1']
    )
);

Controller Action Method

class apiLoginController extends Controller
{
    use ThrottlesLogins;

    public function AuthenticateUser(LoginRequest $request) {        
        //If request fails then calling `$this->TotalAttemptsLeft($request)`
        'Message'   =>  "Invalid credentials" . $this->TotalAttemptsLeft($request) 
                                              . " attempts left.",
    }
}

Throttle Login Trait

trait ThrottlesLogins
{
    protected function TotalAttemptsLeft($request) {
        return $this->limiter()->retriesLeft($this->resolveRequestSignature($request), 6);
    }

    protected function resolveRequestSignature($request)
    {
        return $request->fingerprint();
    }

}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2i2xL4x
via IFTTT

Aucun commentaire:

Enregistrer un commentaire