From 9a5049fdc22603d7906cd7bf79155bea227c8706 Mon Sep 17 00:00:00 2001
From: Adam Wood <1017872+adamwoodnz@users.noreply.github.com>
Date: Wed, 14 Aug 2024 13:31:13 +1200
Subject: [PATCH] Require explicit action to create backup codes
---
settings/src/components/backup-codes.js | 59 +++++++++++--------------
1 file changed, 26 insertions(+), 33 deletions(-)
diff --git a/settings/src/components/backup-codes.js b/settings/src/components/backup-codes.js
index 22630d3f..193e20d5 100644
--- a/settings/src/components/backup-codes.js
+++ b/settings/src/components/backup-codes.js
@@ -24,10 +24,9 @@ import DownloadButton from './download-button';
*/
export default function BackupCodes( { onSuccess = () => {} } ) {
const {
- user: { backupCodesEnabled, hasPrimaryProvider, backupCodesRemaining },
- backupCodesVerified,
+ user: { hasPrimaryProvider },
} = useContext( GlobalContext );
- const [ regenerating, setRegenerating ] = useState( false );
+ const [ generating, setGenerating ] = useState( false );
// Prevent users from accessing directly through the URL.
if ( ! hasPrimaryProvider ) {
@@ -41,26 +40,21 @@ export default function BackupCodes( { onSuccess = () => {} } ) {
);
}
- if (
- ! backupCodesEnabled ||
- backupCodesRemaining === 0 ||
- regenerating ||
- ! backupCodesVerified
- ) {
- return
- Backup codes let you access your account if your primary two-factor - authentication method is unavailable, like if your phone is lost or stolen. Each - code can only be used once. -
+Please print the codes and keep them in a safe place.
@@ -202,33 +192,36 @@ function CodeList( { codes } ) { ); } +const IntroText = () => ( ++ Backup codes let you access your account if your primary two-factor authentication method is + unavailable, like if your phone is lost or stolen. Each code can only be used once. +
+); + /** * Render the screen where users can manage Backup Codes. * * @param props - * @param props.setRegenerating + * @param props.setGenerating */ -function Manage( { setRegenerating } ) { +function Manage( { setGenerating } ) { const { - user: { backupCodesRemaining }, + user: { backupCodesEnabled, backupCodesRemaining }, } = useContext( GlobalContext ); return ( <>- Backup codes let you access your account if your primary two-factor - authentication method is unavailable, like if your phone is lost or stolen. Each - code can only be used once. -
+You have { backupCodesRemaining } backup codes remaining.
) } - { backupCodesRemaining <= 5 && ( + { backupCodesEnabled && backupCodesRemaining <= 5 && (