Skip to content

Commit

Permalink
Merge pull request #29985 from Expensify/monil-fix2FAAPICall
Browse files Browse the repository at this point in the history
Prevent multiple redundant API calls for 2FA
  • Loading branch information
cristipaval authored Oct 23, 2023
2 parents 1343196 + 75b410e commit ed5009d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ function CodesStep({account = defaultAccount}) {
const {setStep} = useTwoFactorAuthContext();

useEffect(() => {
if (account.recoveryCodes) {
if (account.requiresTwoFactorAuth || account.recoveryCodes) {
return;
}
Session.toggleTwoFactorAuth(true);
}, [account.recoveryCodes]);
// eslint-disable-next-line react-hooks/exhaustive-deps -- We want to run this when component mounts
}, []);

return (
<StepWrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const TwoFactorAuthPropTypes = {
const defaultAccount = {
requiresTwoFactorAuth: false,
twoFactorAuthStep: '',
recoveryCodes: '',
};

export {TwoFactorAuthPropTypes, defaultAccount};

0 comments on commit ed5009d

Please sign in to comment.