From 60b155d469206085908b620b64a3a68d3f715ea5 Mon Sep 17 00:00:00 2001 From: Monil Bhavsar Date: Wed, 1 Nov 2023 23:17:08 +0530 Subject: [PATCH 1/9] Redirect to 2FA page with backTo route --- src/ROUTES.ts | 5 ++++- src/libs/Navigation/linkingConfig.js | 2 +- .../ReimbursementAccount/Enable2FAPrompt.js | 16 ++++++++++------ .../ReimbursementAccountPage.js | 1 + src/pages/ReimbursementAccount/ValidationStep.js | 10 +++++++--- .../settings/Security/SecuritySettingsPage.js | 2 +- 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index bcc4685368cb..006c6ff19bb5 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -117,7 +117,10 @@ export default { getRoute: (contactMethod: string) => `settings/profile/contact-methods/${encodeURIComponent(contactMethod)}/details`, }, SETTINGS_NEW_CONTACT_METHOD: 'settings/profile/contact-methods/new', - SETTINGS_2FA: 'settings/security/two-factor-auth', + SETTINGS_2FA: { + route: 'settings/security/two-factor-auth', + getRoute: (backTo?: string) => getUrlWithBackToParam('settings/security/two-factor-auth', backTo), + }, SETTINGS_STATUS: 'settings/profile/status', SETTINGS_STATUS_SET: 'settings/profile/status/set', diff --git a/src/libs/Navigation/linkingConfig.js b/src/libs/Navigation/linkingConfig.js index b2db1758f24b..e9e2b6dcbc91 100644 --- a/src/libs/Navigation/linkingConfig.js +++ b/src/libs/Navigation/linkingConfig.js @@ -176,7 +176,7 @@ export default { exact: true, }, Settings_TwoFactorAuth: { - path: ROUTES.SETTINGS_2FA, + path: ROUTES.SETTINGS_2FA.route, exact: true, }, Settings_Share_Code: { diff --git a/src/pages/ReimbursementAccount/Enable2FAPrompt.js b/src/pages/ReimbursementAccount/Enable2FAPrompt.js index c768f901508e..6262086e147a 100644 --- a/src/pages/ReimbursementAccount/Enable2FAPrompt.js +++ b/src/pages/ReimbursementAccount/Enable2FAPrompt.js @@ -8,35 +8,39 @@ import withLocalize, {withLocalizePropTypes} from '@components/withLocalize'; import styles from '@styles/styles'; import * as Link from '@userActions/Link'; import ROUTES from '@src/ROUTES'; +import Navigation from "@navigation/Navigation"; +import PropTypes from "prop-types"; const propTypes = { ...withLocalizePropTypes, + + policyID: PropTypes.string.isRequired, }; -function Enable2FAPrompt(props) { +function Enable2FAPrompt({translate, policyID}) { const secureYourAccountUrl = encodeURI( `settings?param={"section":"account","action":"enableTwoFactorAuth","exitTo":"${ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute()}","isFromNewDot":"true"}`, ); return (
{ - Link.openOldDotLink(secureYourAccountUrl); + Navigation.navigate(ROUTES.SETTINGS_2FA.getRoute(ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute('', policyID))); }, icon: Expensicons.Shield, shouldShowRightIcon: true, iconRight: Expensicons.NewWindow, wrapperStyle: [styles.cardMenuItem], - link: () => Link.buildOldDotURL(secureYourAccountUrl), + link: () => Navigation.navigate(ROUTES.SETTINGS_2FA.getRoute(ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute('', policyID))), }, ]} > - {props.translate('validationStep.enable2FAText')} + {translate('validationStep.enable2FAText')}
); diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js index 35fa1261f9dc..c7a2615e1119 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js @@ -518,6 +518,7 @@ class ReimbursementAccountPage extends React.Component { ); } diff --git a/src/pages/ReimbursementAccount/ValidationStep.js b/src/pages/ReimbursementAccount/ValidationStep.js index 5a0149aa3ba4..98b6344e1d76 100644 --- a/src/pages/ReimbursementAccount/ValidationStep.js +++ b/src/pages/ReimbursementAccount/ValidationStep.js @@ -43,6 +43,8 @@ const propTypes = { /** If user has two-factor authentication enabled */ requiresTwoFactorAuth: PropTypes.bool, }), + + policyID: PropTypes.string.isRequired, }; const defaultProps = { @@ -73,7 +75,9 @@ const filterInput = (amount) => { return value; }; -function ValidationStep({reimbursementAccount, translate, onBackButtonPress, account}) { +function ValidationStep({reimbursementAccount, translate, onBackButtonPress, account, policyID}) { + console.debug(`~~Monil policyID ${policyID}`); + /** * @param {Object} values - form input values passed by the Form component * @returns {Object} @@ -179,7 +183,7 @@ function ValidationStep({reimbursementAccount, translate, onBackButtonPress, acc {!requiresTwoFactorAuth && ( - + )} @@ -210,7 +214,7 @@ function ValidationStep({reimbursementAccount, translate, onBackButtonPress, acc /> {reimbursementAccount.shouldShowResetModal && } - {!requiresTwoFactorAuth && } + {!requiresTwoFactorAuth && } )} diff --git a/src/pages/settings/Security/SecuritySettingsPage.js b/src/pages/settings/Security/SecuritySettingsPage.js index 1bd6310ec97f..ce14fa25851a 100644 --- a/src/pages/settings/Security/SecuritySettingsPage.js +++ b/src/pages/settings/Security/SecuritySettingsPage.js @@ -42,7 +42,7 @@ function SecuritySettingsPage(props) { { translationKey: 'twoFactorAuth.headerTitle', icon: Expensicons.Shield, - action: waitForNavigate(() => Navigation.navigate(ROUTES.SETTINGS_2FA)), + action: waitForNavigate(() => Navigation.navigate(ROUTES.SETTINGS_2FA.getRoute())), }, { translationKey: 'closeAccountPage.closeAccount', From 8ee188a2f6f2169d268b383658dae8cb251e328c Mon Sep 17 00:00:00 2001 From: Monil Bhavsar Date: Thu, 2 Nov 2023 01:09:45 +0530 Subject: [PATCH 2/9] Redirect to backTo route --- src/pages/ReimbursementAccount/Enable2FAPrompt.js | 13 +++++-------- .../Security/TwoFactorAuth/Steps/SuccessStep.js | 6 +++++- .../Security/TwoFactorAuth/TwoFactorAuthSteps.js | 9 ++++++++- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/pages/ReimbursementAccount/Enable2FAPrompt.js b/src/pages/ReimbursementAccount/Enable2FAPrompt.js index 6262086e147a..0bf3ca76db75 100644 --- a/src/pages/ReimbursementAccount/Enable2FAPrompt.js +++ b/src/pages/ReimbursementAccount/Enable2FAPrompt.js @@ -4,22 +4,19 @@ import * as Expensicons from '@components/Icon/Expensicons'; import * as Illustrations from '@components/Icon/Illustrations'; import Section from '@components/Section'; import Text from '@components/Text'; -import withLocalize, {withLocalizePropTypes} from '@components/withLocalize'; import styles from '@styles/styles'; -import * as Link from '@userActions/Link'; import ROUTES from '@src/ROUTES'; import Navigation from "@navigation/Navigation"; import PropTypes from "prop-types"; +import withLocalize, {withLocalizePropTypes} from "@components/withLocalize"; +import useLocalize from "@hooks/useLocalize"; const propTypes = { - ...withLocalizePropTypes, - policyID: PropTypes.string.isRequired, }; -function Enable2FAPrompt({translate, policyID}) { - const secureYourAccountUrl = encodeURI( - `settings?param={"section":"account","action":"enableTwoFactorAuth","exitTo":"${ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute()}","isFromNewDot":"true"}`, - ); + +function Enable2FAPrompt({policyID}) { + const {translate} = useLocalize(); return (
{ TwoFactorAuthActions.clearTwoFactorAuthData(); setStep(CONST.TWO_FACTOR_AUTH_STEPS.ENABLED); + if (backTo) { + Navigation.navigate(backTo); + } }} /> diff --git a/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthSteps.js b/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthSteps.js index 31a33efa3996..28fc05f83c8f 100644 --- a/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthSteps.js +++ b/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthSteps.js @@ -1,4 +1,5 @@ import React, {useCallback, useEffect, useMemo, useState} from 'react'; +import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import useAnimatedStepContext from '@components/AnimatedStep/useAnimatedStepContext'; import * as TwoFactorAuthActions from '@userActions/TwoFactorAuthActions'; @@ -11,8 +12,14 @@ import SuccessStep from './Steps/SuccessStep'; import VerifyStep from './Steps/VerifyStep'; import TwoFactorAuthContext from './TwoFactorAuthContext'; import {defaultAccount, TwoFactorAuthPropTypes} from './TwoFactorAuthPropTypes'; +import {useRoute} from "@react-navigation/native"; +import lodashGet from "lodash/get"; function TwoFactorAuthSteps({account = defaultAccount}) { + const route = useRoute(); + const backTo = lodashGet(route.params, 'backTo', ''); + console.debug(`~~Monil logs backTo ${backTo}`); + const [currentStep, setCurrentStep] = useState(CONST.TWO_FACTOR_AUTH_STEPS.CODES); const {setAnimationDirection} = useAnimatedStepContext(); @@ -49,7 +56,7 @@ function TwoFactorAuthSteps({account = defaultAccount}) { case CONST.TWO_FACTOR_AUTH_STEPS.VERIFY: return ; case CONST.TWO_FACTOR_AUTH_STEPS.SUCCESS: - return ; + return ; case CONST.TWO_FACTOR_AUTH_STEPS.ENABLED: return ; case CONST.TWO_FACTOR_AUTH_STEPS.DISABLED: From 27846226e767d5dc0663eb26b927f3aeb9f2507c Mon Sep 17 00:00:00 2001 From: Monil Bhavsar Date: Thu, 2 Nov 2023 11:18:49 +0530 Subject: [PATCH 3/9] Lint fix --- src/pages/ReimbursementAccount/Enable2FAPrompt.js | 7 +++---- .../Security/TwoFactorAuth/Steps/SuccessStep.js | 12 ++++++++++++ .../Security/TwoFactorAuth/TwoFactorAuthSteps.js | 5 ++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/pages/ReimbursementAccount/Enable2FAPrompt.js b/src/pages/ReimbursementAccount/Enable2FAPrompt.js index 0bf3ca76db75..6f81291cd596 100644 --- a/src/pages/ReimbursementAccount/Enable2FAPrompt.js +++ b/src/pages/ReimbursementAccount/Enable2FAPrompt.js @@ -9,15 +9,14 @@ import ROUTES from '@src/ROUTES'; import Navigation from "@navigation/Navigation"; import PropTypes from "prop-types"; import withLocalize, {withLocalizePropTypes} from "@components/withLocalize"; -import useLocalize from "@hooks/useLocalize"; const propTypes = { + ...withLocalizePropTypes, + policyID: PropTypes.string.isRequired, }; -function Enable2FAPrompt({policyID}) { - const {translate} = useLocalize(); - +function Enable2FAPrompt({translate, policyID}) { return (
Date: Thu, 2 Nov 2023 12:40:22 +0530 Subject: [PATCH 4/9] Lint fix and describe props --- src/pages/ReimbursementAccount/Enable2FAPrompt.js | 8 ++++---- src/pages/ReimbursementAccount/ValidationStep.js | 3 +-- .../settings/Security/TwoFactorAuth/Steps/SuccessStep.js | 9 +++++---- .../Security/TwoFactorAuth/TwoFactorAuthSteps.js | 5 ++--- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/pages/ReimbursementAccount/Enable2FAPrompt.js b/src/pages/ReimbursementAccount/Enable2FAPrompt.js index 6f81291cd596..445f29cba228 100644 --- a/src/pages/ReimbursementAccount/Enable2FAPrompt.js +++ b/src/pages/ReimbursementAccount/Enable2FAPrompt.js @@ -1,18 +1,19 @@ +import PropTypes from 'prop-types'; import React from 'react'; import {View} from 'react-native'; import * as Expensicons from '@components/Icon/Expensicons'; import * as Illustrations from '@components/Icon/Illustrations'; import Section from '@components/Section'; import Text from '@components/Text'; +import withLocalize, {withLocalizePropTypes} from '@components/withLocalize'; +import Navigation from '@navigation/Navigation'; import styles from '@styles/styles'; import ROUTES from '@src/ROUTES'; -import Navigation from "@navigation/Navigation"; -import PropTypes from "prop-types"; -import withLocalize, {withLocalizePropTypes} from "@components/withLocalize"; const propTypes = { ...withLocalizePropTypes, + /** policyID of the workspace where user is setting up bank account */ policyID: PropTypes.string.isRequired, }; @@ -31,7 +32,6 @@ function Enable2FAPrompt({translate, policyID}) { shouldShowRightIcon: true, iconRight: Expensicons.NewWindow, wrapperStyle: [styles.cardMenuItem], - link: () => Navigation.navigate(ROUTES.SETTINGS_2FA.getRoute(ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute('', policyID))), }, ]} > diff --git a/src/pages/ReimbursementAccount/ValidationStep.js b/src/pages/ReimbursementAccount/ValidationStep.js index 98b6344e1d76..a916af5b0e05 100644 --- a/src/pages/ReimbursementAccount/ValidationStep.js +++ b/src/pages/ReimbursementAccount/ValidationStep.js @@ -44,6 +44,7 @@ const propTypes = { requiresTwoFactorAuth: PropTypes.bool, }), + /** policyID of the workspace where user is setting up bank account */ policyID: PropTypes.string.isRequired, }; @@ -76,8 +77,6 @@ const filterInput = (amount) => { }; function ValidationStep({reimbursementAccount, translate, onBackButtonPress, account, policyID}) { - console.debug(`~~Monil policyID ${policyID}`); - /** * @param {Object} values - form input values passed by the Form component * @returns {Object} diff --git a/src/pages/settings/Security/TwoFactorAuth/Steps/SuccessStep.js b/src/pages/settings/Security/TwoFactorAuth/Steps/SuccessStep.js index 11cd0e8bd6c7..068d886e8509 100644 --- a/src/pages/settings/Security/TwoFactorAuth/Steps/SuccessStep.js +++ b/src/pages/settings/Security/TwoFactorAuth/Steps/SuccessStep.js @@ -1,21 +1,22 @@ +import PropTypes from 'prop-types'; import React from 'react'; import ConfirmationPage from '@components/ConfirmationPage'; import * as LottieAnimations from '@components/LottieAnimations'; import useLocalize from '@hooks/useLocalize'; +import Navigation from '@navigation/Navigation'; import StepWrapper from '@pages/settings/Security/TwoFactorAuth/StepWrapper/StepWrapper'; import useTwoFactorAuthContext from '@pages/settings/Security/TwoFactorAuth/TwoFactorAuthContext/useTwoFactorAuth'; import * as TwoFactorAuthActions from '@userActions/TwoFactorAuthActions'; import CONST from '@src/CONST'; -import Navigation from "@navigation/Navigation"; -import PropTypes from "prop-types"; const propTypes = { + /** The route where user needs to be redirected after setting up 2FA */ backTo: PropTypes.string, -} +}; const defaultProps = { backTo: '', -} +}; function SuccessStep({backTo}) { const {setStep} = useTwoFactorAuthContext(); diff --git a/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthSteps.js b/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthSteps.js index b633bc40723a..8d3427433060 100644 --- a/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthSteps.js +++ b/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthSteps.js @@ -1,11 +1,11 @@ +import {useRoute} from '@react-navigation/native'; +import lodashGet from 'lodash/get'; import React, {useCallback, useEffect, useMemo, useState} from 'react'; import {withOnyx} from 'react-native-onyx'; import useAnimatedStepContext from '@components/AnimatedStep/useAnimatedStepContext'; import * as TwoFactorAuthActions from '@userActions/TwoFactorAuthActions'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import lodashGet from "lodash/get"; -import {useRoute} from "@react-navigation/native"; import CodesStep from './Steps/CodesStep'; import DisabledStep from './Steps/DisabledStep'; import EnabledStep from './Steps/EnabledStep'; @@ -17,7 +17,6 @@ import {defaultAccount, TwoFactorAuthPropTypes} from './TwoFactorAuthPropTypes'; function TwoFactorAuthSteps({account = defaultAccount}) { const route = useRoute(); const backTo = lodashGet(route.params, 'backTo', ''); - console.debug(`~~Monil logs backTo ${backTo}`); const [currentStep, setCurrentStep] = useState(CONST.TWO_FACTOR_AUTH_STEPS.CODES); From aa245640a391d0900e4944ee42e924c6c6a71f51 Mon Sep 17 00:00:00 2001 From: Monil Bhavsar Date: Tue, 21 Nov 2023 15:25:41 +0530 Subject: [PATCH 5/9] Lint fix --- src/pages/ReimbursementAccount/Enable2FAPrompt.js | 3 +-- .../settings/Security/TwoFactorAuth/TwoFactorAuthSteps.js | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pages/ReimbursementAccount/Enable2FAPrompt.js b/src/pages/ReimbursementAccount/Enable2FAPrompt.js index 44da2eeb09eb..a80e0a22cdc0 100644 --- a/src/pages/ReimbursementAccount/Enable2FAPrompt.js +++ b/src/pages/ReimbursementAccount/Enable2FAPrompt.js @@ -5,13 +5,12 @@ import * as Expensicons from '@components/Icon/Expensicons'; import * as Illustrations from '@components/Icon/Illustrations'; import Section from '@components/Section'; import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; import Navigation from '@navigation/Navigation'; import useThemeStyles from '@styles/useThemeStyles'; import ROUTES from '@src/ROUTES'; -import useLocalize from "@hooks/useLocalize"; const propTypes = { - /** policyID of the workspace where user is setting up bank account */ policyID: PropTypes.string.isRequired, }; diff --git a/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthSteps.js b/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthSteps.js index 5e677447e0f6..20fc3991be3a 100644 --- a/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthSteps.js +++ b/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthSteps.js @@ -24,7 +24,6 @@ function TwoFactorAuthSteps({account = defaultAccount}) { return account.requiresTwoFactorAuth ? CONST.TWO_FACTOR_AUTH_STEPS.ENABLED : CONST.TWO_FACTOR_AUTH_STEPS.CODES; }, [account.requiresTwoFactorAuth, account.twoFactorAuthStep]); - const {setAnimationDirection} = useAnimatedStepContext(); useEffect(() => () => TwoFactorAuthActions.clearTwoFactorAuthData(), []); From a7fce3bfe89e2604c1d807a0f53a5ec4f123d40f Mon Sep 17 00:00:00 2001 From: Monil Bhavsar Date: Mon, 27 Nov 2023 17:06:38 +0530 Subject: [PATCH 6/9] Handle back navigation case --- src/libs/actions/TwoFactorAuthActions.ts | 8 ++++---- src/pages/ReimbursementAccount/Enable2FAPrompt.js | 11 ++++++----- .../Security/TwoFactorAuth/StepWrapper/StepWrapper.js | 2 +- .../Security/TwoFactorAuth/Steps/CodesStep.js | 3 ++- .../Security/TwoFactorAuth/Steps/DisabledStep.js | 2 +- .../Security/TwoFactorAuth/TwoFactorAuthSteps.js | 4 ++-- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/libs/actions/TwoFactorAuthActions.ts b/src/libs/actions/TwoFactorAuthActions.ts index ccd4e2baf662..c0aa49a895e6 100644 --- a/src/libs/actions/TwoFactorAuthActions.ts +++ b/src/libs/actions/TwoFactorAuthActions.ts @@ -8,7 +8,7 @@ import {TwoFactorAuthStep} from '@src/types/onyx/Account'; * Clear 2FA data if the flow is interrupted without finishing */ function clearTwoFactorAuthData() { - Onyx.merge(ONYXKEYS.ACCOUNT, {recoveryCodes: '', twoFactorAuthSecretKey: '', twoFactorAuthStep: '', codesAreCopied: false}); + Onyx.merge(ONYXKEYS.ACCOUNT, {recoveryCodes: null, twoFactorAuthSecretKey: null, twoFactorAuthStep: null, codesAreCopied: false}); } function setTwoFactorAuthStep(twoFactorAuthStep: TwoFactorAuthStep) { Onyx.merge(ONYXKEYS.ACCOUNT, {twoFactorAuthStep}); @@ -18,9 +18,9 @@ function setCodesAreCopied() { Onyx.merge(ONYXKEYS.ACCOUNT, {codesAreCopied: true}); } -function quitAndNavigateBackToSettings() { +function quitAndNavigateBack(backTo?: string) { clearTwoFactorAuthData(); - Navigation.goBack(ROUTES.SETTINGS_SECURITY); + Navigation.goBack(backTo ? backTo : ROUTES.SETTINGS_SECURITY); } -export {clearTwoFactorAuthData, setTwoFactorAuthStep, quitAndNavigateBackToSettings, setCodesAreCopied}; +export {clearTwoFactorAuthData, setTwoFactorAuthStep, quitAndNavigateBack, setCodesAreCopied}; diff --git a/src/pages/ReimbursementAccount/Enable2FAPrompt.js b/src/pages/ReimbursementAccount/Enable2FAPrompt.js index a80e0a22cdc0..279830888d8e 100644 --- a/src/pages/ReimbursementAccount/Enable2FAPrompt.js +++ b/src/pages/ReimbursementAccount/Enable2FAPrompt.js @@ -5,19 +5,20 @@ import * as Expensicons from '@components/Icon/Expensicons'; import * as Illustrations from '@components/Icon/Illustrations'; import Section from '@components/Section'; import Text from '@components/Text'; -import useLocalize from '@hooks/useLocalize'; import Navigation from '@navigation/Navigation'; import useThemeStyles from '@styles/useThemeStyles'; import ROUTES from '@src/ROUTES'; +import withLocalize, {withLocalizePropTypes} from "@components/withLocalize"; const propTypes = { + ...withLocalizePropTypes, + /** policyID of the workspace where user is setting up bank account */ policyID: PropTypes.string.isRequired, }; -function Enable2FAPrompt(props) { +function Enable2FAPrompt({translate, policyID}) { const styles = useThemeStyles(); - const {translate} = useLocalize(); return (
{ - Navigation.navigate(ROUTES.SETTINGS_2FA.getRoute(ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute('', props.policyID))); + Navigation.navigate(ROUTES.SETTINGS_2FA.getRoute(ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute('', policyID))); }, icon: Expensicons.Shield, shouldShowRightIcon: true, @@ -46,4 +47,4 @@ function Enable2FAPrompt(props) { Enable2FAPrompt.propTypes = propTypes; Enable2FAPrompt.displayName = 'Enable2FAPrompt'; -export default Enable2FAPrompt; +export default withLocalize(Enable2FAPrompt); diff --git a/src/pages/settings/Security/TwoFactorAuth/StepWrapper/StepWrapper.js b/src/pages/settings/Security/TwoFactorAuth/StepWrapper/StepWrapper.js index bd1068693785..02e4f2b5cf45 100644 --- a/src/pages/settings/Security/TwoFactorAuth/StepWrapper/StepWrapper.js +++ b/src/pages/settings/Security/TwoFactorAuth/StepWrapper/StepWrapper.js @@ -11,7 +11,7 @@ import StepWrapperPropTypes from './StepWrapperPropTypes'; function StepWrapper({ title = '', stepCounter = null, - onBackButtonPress = TwoFactorAuthActions.quitAndNavigateBackToSettings, + onBackButtonPress = TwoFactorAuthActions.quitAndNavigateBack, children = null, shouldEnableKeyboardAvoidingView = true, onEntryTransitionEnd, diff --git a/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.js b/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.js index bc85b01cd3da..86d218ec63ae 100644 --- a/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.js +++ b/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.js @@ -24,7 +24,7 @@ import * as TwoFactorAuthActions from '@userActions/TwoFactorAuthActions'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -function CodesStep({account = defaultAccount}) { +function CodesStep({account = defaultAccount, backTo}) { const theme = useTheme(); const styles = useThemeStyles(); const {translate} = useLocalize(); @@ -50,6 +50,7 @@ function CodesStep({account = defaultAccount}) { text: translate('twoFactorAuth.stepCodes'), total: 3, }} + onBackButtonPress={() => TwoFactorAuthActions.quitAndNavigateBack(backTo)} >
diff --git a/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthSteps.js b/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthSteps.js index 9d7e83ea6f64..720c2e02b3c0 100644 --- a/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthSteps.js +++ b/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthSteps.js @@ -49,7 +49,7 @@ function TwoFactorAuthSteps({account = defaultAccount}) { const renderStep = () => { switch (currentStep) { case CONST.TWO_FACTOR_AUTH_STEPS.CODES: - return ; + return ; case CONST.TWO_FACTOR_AUTH_STEPS.VERIFY: return ; case CONST.TWO_FACTOR_AUTH_STEPS.SUCCESS: @@ -59,7 +59,7 @@ function TwoFactorAuthSteps({account = defaultAccount}) { case CONST.TWO_FACTOR_AUTH_STEPS.DISABLED: return ; default: - return ; + return ; } }; From 418a67212777e11d8204e624d54d98269b44068b Mon Sep 17 00:00:00 2001 From: Monil Bhavsar Date: Mon, 27 Nov 2023 18:13:53 +0530 Subject: [PATCH 7/9] Fix function usage Co-authored-by: Aimane Chnaif <96077027+aimane-chnaif@users.noreply.github.com> --- .../settings/Security/TwoFactorAuth/StepWrapper/StepWrapper.js | 2 +- src/pages/settings/Security/TwoFactorAuth/Steps/DisabledStep.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/settings/Security/TwoFactorAuth/StepWrapper/StepWrapper.js b/src/pages/settings/Security/TwoFactorAuth/StepWrapper/StepWrapper.js index 02e4f2b5cf45..69d662ba6e81 100644 --- a/src/pages/settings/Security/TwoFactorAuth/StepWrapper/StepWrapper.js +++ b/src/pages/settings/Security/TwoFactorAuth/StepWrapper/StepWrapper.js @@ -11,7 +11,7 @@ import StepWrapperPropTypes from './StepWrapperPropTypes'; function StepWrapper({ title = '', stepCounter = null, - onBackButtonPress = TwoFactorAuthActions.quitAndNavigateBack, + onBackButtonPress = () => TwoFactorAuthActions.quitAndNavigateBack(), children = null, shouldEnableKeyboardAvoidingView = true, onEntryTransitionEnd, diff --git a/src/pages/settings/Security/TwoFactorAuth/Steps/DisabledStep.js b/src/pages/settings/Security/TwoFactorAuth/Steps/DisabledStep.js index 8cef0240958f..9de25ecb8f4b 100644 --- a/src/pages/settings/Security/TwoFactorAuth/Steps/DisabledStep.js +++ b/src/pages/settings/Security/TwoFactorAuth/Steps/DisabledStep.js @@ -26,7 +26,7 @@ function DisabledStep() {