Skip to content

Commit

Permalink
Fully merge PR #1398
Browse files Browse the repository at this point in the history
  • Loading branch information
dainnilsson committed Feb 15, 2024
2 parents faed716 + 0cf48ad commit c44d65e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
3 changes: 2 additions & 1 deletion helper/helper/fido.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ def _prepare_reset_nfc(device, event, signal):
try:
conn = dev.open_connection(FidoConnection)
if removed:
conn.close()
sleep(1.0) # Wait for the device to settle
return conn
return dev.open_connection(FidoConnection)
conn.close()
except CardConnectionException:
pass # Expected, ignore
Expand Down
2 changes: 1 addition & 1 deletion lib/app/views/elevate_fido_buttons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ElevateFidoButtons extends ConsumerWidget {
duration: const Duration(seconds: 30));
try {
if (await ref.read(rpcProvider).requireValue.elevate()) {
ref.invalidate(rpcProvider);
ref.invalidate(rpcStateProvider);
} else {
await ref.read(withContextProvider)((context) async =>
showMessage(context, l10n.s_permission_denied));
Expand Down
33 changes: 23 additions & 10 deletions lib/app/views/reset_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import 'dart:async';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
Expand All @@ -25,6 +26,7 @@ import '../../app/logging.dart';
import '../../core/models.dart';
import '../../core/state.dart';
import '../../desktop/models.dart';
import '../../desktop/state.dart';
import '../../fido/models.dart';
import '../../fido/state.dart';
import '../../management/models.dart';
Expand All @@ -36,6 +38,7 @@ import '../features.dart' as features;
import '../message.dart';
import '../models.dart';
import '../state.dart';
import 'elevate_fido_buttons.dart';
import 'keys.dart';

final _log = Logger('fido.views.reset_dialog');
Expand Down Expand Up @@ -106,7 +109,12 @@ class _ResetDialogState extends ConsumerState<ResetDialog> {
.contains(widget.data.info.formFactor);
final globalReset = isBio && (supported & Capability.piv.value) != 0;
final l10n = AppLocalizations.of(context)!;

double progress = _currentStep == -1 ? 0.0 : _currentStep / (_totalSteps);
final needsElevation = Platform.isWindows &&
_application == Capability.fido2 &&
!ref.watch(rpcStateProvider.select((state) => state.isAdmin));

return ResponsiveDialog(
title: Text(l10n.s_factory_reset),
key: factoryResetCancel,
Expand Down Expand Up @@ -256,16 +264,21 @@ class _ResetDialogState extends ConsumerState<ResetDialog> {
.bodyMedium
?.copyWith(fontWeight: FontWeight.w700),
),
Text(
switch (_application) {
Capability.oath => l10n.p_warning_disable_credentials,
Capability.piv => l10n.p_warning_piv_reset_desc,
Capability.fido2 => l10n.p_warning_disable_accounts,
_ => globalReset
? l10n.p_warning_global_reset_desc
: l10n.p_factory_reset_desc,
},
),
if (needsElevation) ...[
Text(l10n.p_elevated_permissions_required),
const ElevateFidoButtons(),
] else ...[
Text(
switch (_application) {
Capability.oath => l10n.p_warning_disable_credentials,
Capability.piv => l10n.p_warning_piv_reset_desc,
Capability.fido2 => l10n.p_warning_disable_accounts,
_ => globalReset
? l10n.p_warning_global_reset_desc
: l10n.p_factory_reset_desc,
},
),
],
if (_application == Capability.fido2 && _currentStep >= 0) ...[
Text('${l10n.s_status}: ${_getMessage()}'),
LinearProgressIndicator(value: progress)
Expand Down

0 comments on commit c44d65e

Please sign in to comment.