Skip to content

Commit

Permalink
Fix FIDO PIN state
Browse files Browse the repository at this point in the history
  • Loading branch information
dainnilsson committed Oct 29, 2024
1 parent ed7cac9 commit 7c4b838
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions helper/helper/fido.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ def set_pin(self, params, event, signal):
self._info = self.ctap.get_info()
return RpcResponse(dict(), ["device_info"])
except CtapError as e:
self._token = None
return _handle_pin_error(e, self.client_pin)

@action(condition=lambda self: Config.is_supported(self._info))
Expand Down
5 changes: 4 additions & 1 deletion lib/desktop/fido/state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,12 @@ class _DesktopFidoStateNotifier extends FidoStateNotifier {
_session.setErrorHandler('state-reset', (_) async {
ref.invalidate(_sessionProvider(devicePath));
});
_session.setErrorHandler('auth-required', (_) async {
_session.setErrorHandler('auth-required', (e) async {
final pin = ref.read(_pinProvider(devicePath));
if (pin != null) {
await unlock(pin);
} else {
throw e;
}
});
ref.onDispose(() {
Expand Down Expand Up @@ -153,6 +155,7 @@ class _DesktopFidoStateNotifier extends FidoStateNotifier {
return unlock(newPin);
} on RpcError catch (e) {
if (e.status == 'pin-validation') {
ref.invalidate(_pinProvider);
ref.invalidateSelf();
return PinResult.failed(FidoPinFailureReason.invalidPin(
e.body['retries'], e.body['auth_blocked']));
Expand Down

0 comments on commit 7c4b838

Please sign in to comment.