fix: alot

This commit is contained in:
2026-10-19 21:41:34 +02:00
parent 30dd74af90
commit b0074aeb3f
40 changed files with 1979 additions and 405 deletions
+5 -2
View File
@@ -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,