@@ -10,7 +10,7 @@ class AuthenticatorImpl with WidgetsBindingObserver implements Authenticator {
10
10
@override
11
11
final Duration lockedOutDuration;
12
12
@override
13
- final int maxRetries ;
13
+ final int maxTries ;
14
14
@override
15
15
final int pinLength;
16
16
@override
@@ -30,7 +30,7 @@ class AuthenticatorImpl with WidgetsBindingObserver implements Authenticator {
30
30
this ._repository,
31
31
this ._biometricAuth,
32
32
this ._lockController,
33
- this .maxRetries ,
33
+ this .maxTries ,
34
34
this .lockedOutDuration,
35
35
this .lockAfterDuration,
36
36
this .pinLength,
@@ -255,6 +255,9 @@ class AuthenticatorImpl with WidgetsBindingObserver implements Authenticator {
255
255
final userPin = await _repository.getPin (forUser: userId);
256
256
if (userPin? .value != pin.value) {
257
257
await _repository.addFailedAttempt (DateTime .now (), forUser: userId);
258
+ if (await _isLockedDueToTooManyAttempts ()) {
259
+ return const Left (LocalAuthFailure .tooManyAttempts);
260
+ }
258
261
return const Left (LocalAuthFailure .wrongPin);
259
262
}
260
263
await _repository.resetFailedAttempts (ofUser: userId);
@@ -313,6 +316,9 @@ class AuthenticatorImpl with WidgetsBindingObserver implements Authenticator {
313
316
final userPin = await _repository.getPin (forUser: userId);
314
317
if (userPin? .value != pin.value) {
315
318
await _repository.addFailedAttempt (DateTime .now (), forUser: userId);
319
+ if (await _isLockedDueToTooManyAttempts ()) {
320
+ return false ;
321
+ }
316
322
return false ;
317
323
}
318
324
await _repository.resetFailedAttempts (ofUser: userId);
@@ -328,7 +334,7 @@ class AuthenticatorImpl with WidgetsBindingObserver implements Authenticator {
328
334
329
335
Future <bool > _isLockedDueToTooManyAttempts () async {
330
336
final failedAttemptsList = await _repository.getListOfFailedAttempts (userId: userId);
331
- if (failedAttemptsList.length > maxRetries ) {
337
+ if (failedAttemptsList.length >= maxTries ) {
332
338
if (DateTime .now ().difference (failedAttemptsList.last) < lockedOutDuration) {
333
339
return true ;
334
340
}
0 commit comments