Only allow shorter FIDO PIN when changing PIN, if forcePinChange

This commit is contained in:
Dain Nilsson 2024-03-06 21:22:31 +01:00
parent 3245c0d637
commit 442714ac29
No known key found for this signature in database
GPG Key ID: F04367096FBA95E8
2 changed files with 12 additions and 6 deletions

View File

@ -69,8 +69,12 @@ class _FidoPinDialogState extends ConsumerState<FidoPinDialog> {
final l10n = AppLocalizations.of(context)!;
final hasPin = widget.state.hasPin;
final minPinLength = widget.state.minPinLength;
// N.B. current PIN may be shorter than minimum, if it was set before the minimum was increased
final currentPinLenOk = !hasPin || _currentPinController.text.length >= 4;
final currentMinPinLen = !hasPin
? 0
// N.B. current PIN may be shorter than minimum if set before the minimum was increased
: (widget.state.forcePinChange ? 4 : widget.state.minPinLength);
final currentPinLenOk =
_currentPinController.text.length >= currentMinPinLen;
final newPinLenOk = _newPin.length >= minPinLength;
final isValid = currentPinLenOk && newPinLenOk && _newPin == _confirmPin;

View File

@ -148,10 +148,12 @@ class _PinEntryFormState extends ConsumerState<PinEntryForm> {
key: unlockFido2WithPin,
icon: const Icon(Symbols.lock_open),
label: Text(l10n.s_unlock),
onPressed:
!_pinIsWrong && _pinController.text.length >= 4 && !_blocked
? _submit
: null,
onPressed: !_pinIsWrong &&
_pinController.text.length >=
widget._state.minPinLength &&
!_blocked
? _submit
: null,
),
),
],