From 495f8e3b730de862f5ae659588ffa5c2a7ae1780 Mon Sep 17 00:00:00 2001 From: Dysto coder Date: Mon, 24 Jun 2024 12:18:06 +0300 Subject: [PATCH 01/19] Create ValidateAccountMessage file and declare a function --- src/components/ValidateAccountMessage.tsx | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/components/ValidateAccountMessage.tsx diff --git a/src/components/ValidateAccountMessage.tsx b/src/components/ValidateAccountMessage.tsx new file mode 100644 index 000000000000..e69de29bb2d1 From 8071028df1538ffba30681c628dac748639aaf69 Mon Sep 17 00:00:00 2001 From: Dysto coder Date: Mon, 24 Jun 2024 12:32:42 +0300 Subject: [PATCH 02/19] Import utils and components required for the component --- src/components/ValidateAccountMessage.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/components/ValidateAccountMessage.tsx b/src/components/ValidateAccountMessage.tsx index e69de29bb2d1..4f70cadbc040 100644 --- a/src/components/ValidateAccountMessage.tsx +++ b/src/components/ValidateAccountMessage.tsx @@ -0,0 +1,16 @@ +import React from 'react'; +import {View} from 'react-native'; +import Icon from '@components/Icon'; +import * as Expensicons from '@components/Icon/Expensicons'; +import Text from '@components/Text'; +import TextLink from '@components/TextLink'; +import useLocalize from '@hooks/useLocalize'; +import useTheme from '@hooks/useTheme'; +import useThemeStyles from '@hooks/useThemeStyles'; +import variables from '@styles/variables'; +import * as Session from '@userActions/Session'; +function ValidateAccountMessage () { + +} + +export default ValidateAccountMessage; \ No newline at end of file From f3c883b48b2f4375b4b410dd7645e9b9da135f20 Mon Sep 17 00:00:00 2001 From: Dysto coder Date: Mon, 24 Jun 2024 12:34:32 +0300 Subject: [PATCH 03/19] Intialize theme, styles, and transalte hooks --- src/components/ValidateAccountMessage.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/ValidateAccountMessage.tsx b/src/components/ValidateAccountMessage.tsx index 4f70cadbc040..d2037a256659 100644 --- a/src/components/ValidateAccountMessage.tsx +++ b/src/components/ValidateAccountMessage.tsx @@ -11,6 +11,10 @@ import variables from '@styles/variables'; import * as Session from '@userActions/Session'; function ValidateAccountMessage () { + const theme = useTheme(); + const styles = useThemeStyles(); + const {translate} = useLocalize(); + } export default ValidateAccountMessage; \ No newline at end of file From 99fc4ec17881bc798f656c4111fcb1ba63a3d004 Mon Sep 17 00:00:00 2001 From: Dysto coder Date: Mon, 24 Jun 2024 12:57:26 +0300 Subject: [PATCH 04/19] Add BankAccountStep Error message style with SignOut functionality --- src/components/ValidateAccountMessage.tsx | 33 +++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/components/ValidateAccountMessage.tsx b/src/components/ValidateAccountMessage.tsx index d2037a256659..d95d6d2c4596 100644 --- a/src/components/ValidateAccountMessage.tsx +++ b/src/components/ValidateAccountMessage.tsx @@ -9,12 +9,41 @@ import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import variables from '@styles/variables'; import * as Session from '@userActions/Session'; -function ValidateAccountMessage () { +function ValidateAccountMessage() { const theme = useTheme(); const styles = useThemeStyles(); const {translate} = useLocalize(); + return ( + + + + + {translate('bankAccount.validateAccountError.phrase1')} + Session.signOutAndRedirectToSignIn()} + > + {translate('bankAccount.validateAccountError.phrase2')} + + {translate('bankAccount.validateAccountError.phrase3')} + { + // const login = loginList?.[loginNames?.[0]] ?? {}; + // Navigation.navigate(ROUTES.SETTINGS_CONTACT_METHOD_DETAILS.getRoute(login?.partnerUserID ?? loginNames?.[0])); + }} + > + {translate('bankAccount.validateAccountError.phrase4')} + + . + + + ); } -export default ValidateAccountMessage; \ No newline at end of file +export default ValidateAccountMessage; From ffb7bdae4a7f6860bd8bded1553c1c23f8458789 Mon Sep 17 00:00:00 2001 From: Dysto coder Date: Sat, 29 Jun 2024 18:41:49 +0300 Subject: [PATCH 05/19] Add user type BaseTwoFactorAuthFormOnyxProps --- .../settings/Security/TwoFactorAuth/TwoFactorAuthForm/types.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthForm/types.ts b/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthForm/types.ts index baac250a3d66..977dbc2c8ae6 100644 --- a/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthForm/types.ts +++ b/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthForm/types.ts @@ -1,9 +1,10 @@ import type {ForwardedRef} from 'react'; import type {OnyxEntry} from 'react-native-onyx'; -import type {Account} from '@src/types/onyx'; +import type {Account, User} from '@src/types/onyx'; type BaseTwoFactorAuthFormOnyxProps = { account: OnyxEntry; + user: OnyxEntry; }; type BaseTwoFactorAuthFormRef = { From 32853b595e155181974f3c6c2af431fa94767758 Mon Sep 17 00:00:00 2001 From: Dysto coder Date: Sat, 29 Jun 2024 18:44:09 +0300 Subject: [PATCH 06/19] Fetch user from Onyx --- .../settings/Security/TwoFactorAuth/Steps/CodesStep.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx b/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx index 4d46f18c15ea..d551006528cc 100644 --- a/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx +++ b/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx @@ -27,7 +27,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; type CodesStepProps = BaseTwoFactorAuthFormOnyxProps & BackToParams; -function CodesStep({account, backTo}: CodesStepProps) { +function CodesStep({account, user, backTo}: CodesStepProps) { const theme = useTheme(); const styles = useThemeStyles(); const {translate} = useLocalize(); @@ -151,4 +151,7 @@ CodesStep.displayName = 'CodesStep'; export default withOnyx({ account: {key: ONYXKEYS.ACCOUNT}, + user: { + key: ONYXKEYS.USER, + }, })(CodesStep); From bc5eb7dec68950985f3000b440f33486395ae55a Mon Sep 17 00:00:00 2001 From: Dysto coder Date: Sat, 29 Jun 2024 19:09:15 +0300 Subject: [PATCH 07/19] When user is not validated, hide 2FA section except header and next button --- .../TwoFactorAuth/Steps/CodesStep.tsx | 129 +++++++++--------- 1 file changed, 66 insertions(+), 63 deletions(-) diff --git a/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx b/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx index d551006528cc..c6fc4d7701ea 100644 --- a/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx +++ b/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx @@ -33,6 +33,7 @@ function CodesStep({account, user, backTo}: CodesStepProps) { const {translate} = useLocalize(); const {isExtraSmallScreenWidth, isSmallScreenWidth} = useResponsiveLayout(); const [error, setError] = useState(''); + const isUserValidated = user?.validated; const {setStep} = useTwoFactorAuthContext(); @@ -57,70 +58,72 @@ function CodesStep({account, user, backTo}: CodesStepProps) { onBackButtonPress={() => TwoFactorAuthActions.quitAndNavigateBack(backTo)} > -
- - {translate('twoFactorAuth.codesLoseAccess')} - - - {account?.isLoading ? ( - - - - ) : ( - <> - - {!!account?.recoveryCodes && - account?.recoveryCodes?.split(', ').map((code) => ( - - {code} - - ))} + {isUserValidated && ( +
+ + {translate('twoFactorAuth.codesLoseAccess')} + + + {account?.isLoading ? ( + + - - { - Clipboard.setString(account?.recoveryCodes ?? ''); - setError(''); - TwoFactorAuthActions.setCodesAreCopied(); - }} - styles={[styles.button, styles.buttonMedium, styles.twoFactorAuthCodesButton]} - textStyles={[styles.buttonMediumText]} - accessible={false} - tooltipText="" - tooltipTextChecked="" - /> - { - localFileDownload('two-factor-auth-codes', account?.recoveryCodes ?? ''); - setError(''); - TwoFactorAuthActions.setCodesAreCopied(); - }} - inline={false} - styles={[styles.button, styles.buttonMedium, styles.twoFactorAuthCodesButton]} - textStyles={[styles.buttonMediumText]} - accessible={false} - tooltipText="" - tooltipTextChecked="" - /> - - - )} - -
+ ) : ( + <> + + {!!account?.recoveryCodes && + account?.recoveryCodes?.split(', ').map((code) => ( + + {code} + + ))} + + + { + Clipboard.setString(account?.recoveryCodes ?? ''); + setError(''); + TwoFactorAuthActions.setCodesAreCopied(); + }} + styles={[styles.button, styles.buttonMedium, styles.twoFactorAuthCodesButton]} + textStyles={[styles.buttonMediumText]} + accessible={false} + tooltipText="" + tooltipTextChecked="" + /> + { + localFileDownload('two-factor-auth-codes', account?.recoveryCodes ?? ''); + setError(''); + TwoFactorAuthActions.setCodesAreCopied(); + }} + inline={false} + styles={[styles.button, styles.buttonMedium, styles.twoFactorAuthCodesButton]} + textStyles={[styles.buttonMediumText]} + accessible={false} + tooltipText="" + tooltipTextChecked="" + /> + + + )} +
+
+ )} {!!error && ( Date: Sat, 29 Jun 2024 19:13:20 +0300 Subject: [PATCH 08/19] Disable Next button when user is not validated --- src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx b/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx index c6fc4d7701ea..f9e7ddde84b3 100644 --- a/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx +++ b/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx @@ -135,6 +135,7 @@ function CodesStep({account, user, backTo}: CodesStepProps) {