This repository was archived by the owner on Aug 29, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +150
-205
lines changed Expand file tree Collapse file tree 4 files changed +150
-205
lines changed Original file line number Diff line number Diff line change @@ -48,14 +48,14 @@ class PinLock {
48
48
required UserId userId,
49
49
Duration ? lockedOutDuration,
50
50
Duration ? lockAfterDuration,
51
- int ? maxRetries ,
51
+ int ? maxTries ,
52
52
int ? pinLength,
53
53
}) =>
54
54
AuthenticatorImpl (
55
55
repository,
56
56
biometricAuthenticator,
57
57
lockController,
58
- maxRetries ?? 5 ,
58
+ maxTries ?? 5 ,
59
59
lockedOutDuration ?? const Duration (minutes: 1 ),
60
60
lockAfterDuration ?? const Duration (seconds: 5 ),
61
61
pinLength ?? 4 ,
Original file line number Diff line number Diff line change @@ -17,10 +17,10 @@ abstract class Authenticator with WidgetsBindingObserver {
17
17
18
18
/// The number of times that a pin can be entered incorrectly, before the app
19
19
/// stops accepting unlock attempts for [lockedOutDuration]
20
- int get maxRetries ;
20
+ int get maxTries ;
21
21
22
22
/// A duration for which the app will be locked after the number of times the pin is
23
- /// entered incorrectly exceeds [maxRetries ]
23
+ /// entered incorrectly exceeds [maxTries ]
24
24
Duration get lockedOutDuration;
25
25
26
26
/// The expected lenght of the pin, used to draw the [PinInputWidget]
Original file line number Diff line number Diff line change @@ -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,
@@ -250,6 +250,9 @@ class AuthenticatorImpl with WidgetsBindingObserver implements Authenticator {
250
250
final userPin = await _repository.getPin (forUser: userId);
251
251
if (userPin? .value != pin.value) {
252
252
await _repository.addFailedAttempt (DateTime .now (), forUser: userId);
253
+ if (await _isLockedDueToTooManyAttempts ()) {
254
+ return const Left (LocalAuthFailure .tooManyAttempts);
255
+ }
253
256
return const Left (LocalAuthFailure .wrongPin);
254
257
}
255
258
await _repository.resetFailedAttempts (ofUser: userId);
@@ -303,7 +306,7 @@ class AuthenticatorImpl with WidgetsBindingObserver implements Authenticator {
303
306
304
307
Future <bool > _isLockedDueToTooManyAttempts () async {
305
308
final failedAttemptsList = await _repository.getListOfFailedAttempts (userId: userId);
306
- if (failedAttemptsList.length > maxRetries ) {
309
+ if (failedAttemptsList.length >= maxTries ) {
307
310
if (DateTime .now ().difference (failedAttemptsList.last) < lockedOutDuration) {
308
311
return true ;
309
312
}
You can’t perform that action at this time.
0 commit comments