fix: alot
This commit is contained in:
@@ -20,6 +20,7 @@ class PinLockService {
|
||||
this._saltKey = _defaultSaltKey,
|
||||
this._hashKey = _defaultHashKey,
|
||||
DateTime Function()? clock,
|
||||
this.maxLockout = const Duration(minutes: 15),
|
||||
}) : _storage = storage ?? const FlutterSecureStorage(),
|
||||
_clock = clock ?? DateTime.now;
|
||||
|
||||
@@ -31,13 +32,15 @@ class PinLockService {
|
||||
|
||||
static const _freeAttempts = 5;
|
||||
static const _baseLockout = Duration(seconds: 30);
|
||||
static const _maxLockout = Duration(minutes: 15);
|
||||
|
||||
final FlutterSecureStorage _storage;
|
||||
final String _saltKey;
|
||||
final String _hashKey;
|
||||
final DateTime Function() _clock;
|
||||
|
||||
/// Kept short for the bar PIN so a bartender is never locked out for long.
|
||||
final Duration maxLockout;
|
||||
|
||||
String get _failuresKey => '${_hashKey}_failures';
|
||||
String get _lockedUntilKey => '${_hashKey}_locked_until';
|
||||
|
||||
@@ -113,7 +116,7 @@ class PinLockService {
|
||||
|
||||
final exponent = min(failures - _freeAttempts, 10);
|
||||
final lockout = _baseLockout * (1 << exponent);
|
||||
final capped = lockout > _maxLockout ? _maxLockout : lockout;
|
||||
final capped = lockout > maxLockout ? maxLockout : lockout;
|
||||
|
||||
await _storage.write(
|
||||
key: _lockedUntilKey,
|
||||
|
||||
Reference in New Issue
Block a user