Skip to content

Commit

Permalink
Only require revalidation if a non backup code provider is available
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwoodnz committed May 18, 2023
1 parent 6ffe035 commit 87c111d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions settings/src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ function Main( { userId } ) {
return <Spinner />;
}

const { '2fa_available_providers': availableProviders, '2fa_revalidation': revalidation } =
record;
// Check that there are providers, and that the only provider isn't backup codes.
const hasPrimaryProvider =
!! availableProviders.length &&
! (
availableProviders.length === 1 && availableProviders[ 0 ] === 'Two_Factor_Backup_Codes'
);

let screenContent = (
<Card>
<CardHeader className="wporg-2fa__navigation" size="xSmall">
Expand Down Expand Up @@ -159,8 +168,8 @@ function Main( { userId } ) {
screenContent = <AccountStatus />;
} else if (
twoFactorRequiredScreens.includes( screen ) &&
record[ '2fa_available_providers' ].includes( 'Two_Factor_Totp' ) &&
record[ '2fa_revalidation' ]?.expires_at <= new Date().getTime() / 1000
hasPrimaryProvider &&
revalidation?.expires_at <= new Date().getTime() / 1000
) {
screenContent = (
<>
Expand Down

0 comments on commit 87c111d

Please sign in to comment.