mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-23 02:01:36 +03:00
[OATH] show correct button based on FIPS status
This commit is contained in:
parent
2e48131c9b
commit
4339c60fbd
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Yubico.
|
||||
* Copyright (C) 2023,2024 Yubico.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (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 '../keys.dart' as keys;
|
||||
import '../models.dart';
|
||||
import 'manage_password_dialog.dart';
|
||||
import 'utils.dart';
|
||||
|
||||
Widget oathBuildActions(
|
||||
@ -105,11 +104,7 @@ Widget oathBuildActions(
|
||||
icon: const Icon(Symbols.password),
|
||||
onTap: (context) {
|
||||
Navigator.of(context).popUntil((route) => route.isFirst);
|
||||
showBlurDialog(
|
||||
context: context,
|
||||
builder: (context) =>
|
||||
ManagePasswordDialog(devicePath, oathState),
|
||||
);
|
||||
setManagePassword(context, ref, devicePath, oathState);
|
||||
}),
|
||||
]),
|
||||
],
|
||||
|
@ -186,21 +186,38 @@ class _UnlockedViewState extends ConsumerState<_UnlockedView> {
|
||||
|
||||
if (numCreds == 0) {
|
||||
return MessagePage(
|
||||
actionsBuilder: (context, expanded) => [
|
||||
if (!expanded)
|
||||
ActionChip(
|
||||
label: Text(l10n.s_add_account),
|
||||
onPressed: () async {
|
||||
await addOathAccount(
|
||||
context,
|
||||
ref,
|
||||
widget.devicePath,
|
||||
widget.oathState,
|
||||
);
|
||||
},
|
||||
avatar: const Icon(Symbols.person_add_alt),
|
||||
)
|
||||
],
|
||||
actionsBuilder: (context, expanded) {
|
||||
final (fipsCapable, fipsApproved) = ref
|
||||
.watch(currentDeviceDataProvider)
|
||||
.valueOrNull
|
||||
?.info
|
||||
.getFipsStatus(Capability.oath) ??
|
||||
(false, false);
|
||||
return [
|
||||
if (!expanded && (!fipsCapable || (fipsCapable && fipsApproved)))
|
||||
ActionChip(
|
||||
label: Text(l10n.s_add_account),
|
||||
onPressed: () async {
|
||||
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,
|
||||
capabilities: const [Capability.oath],
|
||||
key: keys.noAccountsView,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Yubico.
|
||||
* Copyright (C) 2022-2024 Yubico.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (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_page.dart';
|
||||
import 'add_multi_account_page.dart';
|
||||
import 'manage_password_dialog.dart';
|
||||
|
||||
/// 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),
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user