[OATH] show correct button based on FIPS status

This commit is contained in:
Adam Velebil 2024-08-21 15:13:13 +02:00
parent 2e48131c9b
commit 4339c60fbd
No known key found for this signature in database
GPG Key ID: C9B1E4A3CBBD2E10
3 changed files with 44 additions and 23 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2023 Yubico. * Copyright (C) 2023,2024 Yubico.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -28,7 +28,6 @@ import '../features.dart' as features;
import '../icon_provider/icon_pack_dialog.dart'; import '../icon_provider/icon_pack_dialog.dart';
import '../keys.dart' as keys; import '../keys.dart' as keys;
import '../models.dart'; import '../models.dart';
import 'manage_password_dialog.dart';
import 'utils.dart'; import 'utils.dart';
Widget oathBuildActions( Widget oathBuildActions(
@ -105,11 +104,7 @@ Widget oathBuildActions(
icon: const Icon(Symbols.password), icon: const Icon(Symbols.password),
onTap: (context) { onTap: (context) {
Navigator.of(context).popUntil((route) => route.isFirst); Navigator.of(context).popUntil((route) => route.isFirst);
showBlurDialog( setManagePassword(context, ref, devicePath, oathState);
context: context,
builder: (context) =>
ManagePasswordDialog(devicePath, oathState),
);
}), }),
]), ]),
], ],

View File

@ -186,21 +186,38 @@ class _UnlockedViewState extends ConsumerState<_UnlockedView> {
if (numCreds == 0) { if (numCreds == 0) {
return MessagePage( return MessagePage(
actionsBuilder: (context, expanded) => [ actionsBuilder: (context, expanded) {
if (!expanded) final (fipsCapable, fipsApproved) = ref
ActionChip( .watch(currentDeviceDataProvider)
label: Text(l10n.s_add_account), .valueOrNull
onPressed: () async { ?.info
await addOathAccount( .getFipsStatus(Capability.oath) ??
context, (false, false);
ref, return [
widget.devicePath, if (!expanded && (!fipsCapable || (fipsCapable && fipsApproved)))
widget.oathState, ActionChip(
); label: Text(l10n.s_add_account),
}, onPressed: () async {
avatar: const Icon(Symbols.person_add_alt), await addOathAccount(
) context,
], ref,
widget.devicePath,
widget.oathState,
);
},
avatar: const Icon(Symbols.person_add_alt),
),
if (!expanded && fipsCapable && !fipsApproved)
ActionChip(
label: Text(l10n.s_set_password),
onPressed: () async {
await setManagePassword(
context, ref, widget.devicePath, widget.oathState);
},
avatar: const Icon(Symbols.person_add_alt),
)
];
},
title: l10n.s_accounts, title: l10n.s_accounts,
capabilities: const [Capability.oath], capabilities: const [Capability.oath],
key: keys.noAccountsView, key: keys.noAccountsView,

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2022 Yubico. * Copyright (C) 2022-2024 Yubico.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -35,6 +35,7 @@ import '../models.dart';
import 'add_account_dialog.dart'; import 'add_account_dialog.dart';
import 'add_account_page.dart'; import 'add_account_page.dart';
import 'add_multi_account_page.dart'; import 'add_multi_account_page.dart';
import 'manage_password_dialog.dart';
/// Calculates the available space for issuer and account name. /// Calculates the available space for issuer and account name.
/// ///
@ -178,3 +179,11 @@ Future<void> addOathAccount(BuildContext context, WidgetRef ref,
); );
} }
} }
Future<void> setManagePassword(BuildContext context, WidgetRef ref,
DevicePath devicePath, OathState oathState) async {
await showBlurDialog(
context: context,
builder: (context) => ManagePasswordDialog(devicePath, oathState),
);
}