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();
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire