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 ; - } - - return ; + return generating ? ( + + ) : ( + + ); } /** * Setup the Backup Codes provider. * * @param props - * @param props.setRegenerating + * @param props.setGenerating * @param props.onSuccess */ -function Setup( { setRegenerating, onSuccess } ) { +function Setup( { setGenerating, onSuccess } ) { const { setGlobalNotice, user: { userRecord }, @@ -110,18 +104,14 @@ function Setup( { setRegenerating, onSuccess } ) { // The codes have already been saved to usermeta, see `generateCodes()` above. setBackupCodesVerified( true ); setGlobalNotice( 'Backup codes have been enabled.' ); - setRegenerating( false ); + setGenerating( false ); onSuccess(); } ); 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. -

+ - { backupCodesRemaining > 5 && ( + { backupCodesEnabled && backupCodesRemaining > 5 && (

You have { backupCodesRemaining } backup codes remaining.

) } - { backupCodesRemaining <= 5 && ( + { backupCodesEnabled && backupCodesRemaining <= 5 && (
@@ -241,8 +234,8 @@ function Manage( { setRegenerating } ) { ) }
- );