Skip to content

Commit

Permalink
Merge pull request #54404 from software-mansion-labs/migrate/animatab…
Browse files Browse the repository at this point in the history
…le-reanimated

Migrate Two Factor Authentication to use separate screens (remove react-native-animatable)
  • Loading branch information
mountiny authored Feb 20, 2025
2 parents bf23769 + 6ba1ae6 commit ac3b408
Show file tree
Hide file tree
Showing 40 changed files with 407 additions and 519 deletions.
4 changes: 2 additions & 2 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4789,12 +4789,12 @@ const CONST = {
CUSTOM: 'custom',
},
TWO_FACTOR_AUTH_STEPS: {
CODES: 'CODES',
COPY_CODES: 'COPY_CODES',
VERIFY: 'VERIFY',
SUCCESS: 'SUCCESS',
ENABLED: 'ENABLED',
DISABLED: 'DISABLED',
GETCODE: 'GETCODE',
DISABLE: 'DISABLE',
},
DELEGATE_ROLE: {
ALL: 'all',
Expand Down
4 changes: 2 additions & 2 deletions src/Expensify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ function Expensify() {
if (!isAuthenticated) {
return;
}
setCrashlyticsUserId(session?.accountID ?? -1);
setCrashlyticsUserId(session?.accountID ?? CONST.DEFAULT_NUMBER_ID);
}, [isAuthenticated, session?.accountID]);

// Display a blank page until the onyx migration completes
Expand Down Expand Up @@ -275,7 +275,7 @@ function Expensify() {
<RequireTwoFactorAuthenticationModal
onSubmit={() => {
setShouldShowRequire2FAModal(false);
Navigation.navigate(ROUTES.SETTINGS_2FA.getRoute(ROUTES.HOME));
Navigation.navigate(ROUTES.SETTINGS_2FA_ROOT.getRoute(ROUTES.HOME));
}}
isVisible
description={translate('twoFactorAuth.twoFactorAuthIsRequiredForAdminsDescription')}
Expand Down
16 changes: 15 additions & 1 deletion src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,25 @@ const ROUTES = {
route: 'settings/profile/contact-methods/new',
getRoute: (backTo?: string) => getUrlWithBackToParam('settings/profile/contact-methods/new', backTo),
},
SETTINGS_2FA: {

SETTINGS_2FA_ROOT: {
route: 'settings/security/two-factor-auth',
getRoute: (backTo?: string, forwardTo?: string) =>
getUrlWithBackToParam(forwardTo ? `settings/security/two-factor-auth?forwardTo=${encodeURIComponent(forwardTo)}` : 'settings/security/two-factor-auth', backTo),
},
SETTINGS_2FA_VERIFY: {
route: 'settings/security/two-factor-auth/verify',
getRoute: (backTo?: string, forwardTo?: string) =>
getUrlWithBackToParam(forwardTo ? `settings/security/two-factor-auth/verify?forwardTo=${encodeURIComponent(forwardTo)}` : 'settings/security/two-factor-auth/verify', backTo),
},
SETTINGS_2FA_SUCCESS: {
route: 'settings/security/two-factor-auth/success',
getRoute: (backTo?: string, forwardTo?: string) =>
getUrlWithBackToParam(forwardTo ? `settings/security/two-factor-auth/success?forwardTo=${encodeURIComponent(forwardTo)}` : 'settings/security/two-factor-auth/success', backTo),
},
SETTINGS_2FA_DISABLED: 'settings/security/two-factor-auth/disabled',
SETTINGS_2FA_DISABLE: 'settings/security/two-factor-auth/disable',

SETTINGS_STATUS: 'settings/profile/status',

SETTINGS_STATUS_CLEAR_AFTER: 'settings/profile/status/clear-after',
Expand Down
9 changes: 8 additions & 1 deletion src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ const SCREENS = {
ADD_BANK_ACCOUNT: 'Settings_Add_Bank_Account',
ADD_US_BANK_ACCOUNT: 'Settings_Add_US_Bank_Account',
CLOSE: 'Settings_Close',
TWO_FACTOR_AUTH: 'Settings_TwoFactorAuth',
REPORT_CARD_LOST_OR_DAMAGED: 'Settings_ReportCardLostOrDamaged',
TROUBLESHOOT: 'Settings_Troubleshoot',
CONSOLE: 'Settings_Console',
Expand Down Expand Up @@ -145,6 +144,13 @@ const SCREENS = {
UPDATE_DELEGATE_ROLE: 'Settings_Delegate_Update_Role',
},
},
TWO_FACTOR_AUTH: {
ROOT: 'Settings_TwoFactorAuth_Root',
VERIFY: 'Settings_TwoFactorAuth_Verify',
SUCCESS: 'Settings_TwoFactorAuth_Success',
DISABLED: 'Settings_TwoFactorAuth_Disabled',
DISABLE: 'Settings_TwoFactorAuth_Disable',
},
SAVE_THE_WORLD: {
ROOT: 'SaveTheWorld_Root',
},
Expand All @@ -153,6 +159,7 @@ const SCREENS = {
},
RIGHT_MODAL: {
SETTINGS: 'Settings',
TWO_FACTOR_AUTH: 'TwoFactorAuth',
NEW_CHAT: 'NewChat',
DETAILS: 'Details',
PROFILE: 'Profile',
Expand Down
16 changes: 0 additions & 16 deletions src/components/AnimatedStep/AnimatedStepContext.ts

This file was deleted.

15 changes: 0 additions & 15 deletions src/components/AnimatedStep/AnimatedStepProvider.tsx

This file was deleted.

48 changes: 0 additions & 48 deletions src/components/AnimatedStep/index.tsx

This file was deleted.

13 changes: 0 additions & 13 deletions src/components/AnimatedStep/useAnimatedStepContext.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/ConnectToXeroFlow/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function ConnectToXeroFlow({policyID}: ConnectToXeroFlowProps) {
<RequireTwoFactorAuthenticationModal
onSubmit={() => {
setIsRequire2FAModalOpen(false);
Navigation.navigate(ROUTES.SETTINGS_2FA.getRoute(ROUTES.POLICY_ACCOUNTING.getRoute(policyID), getXeroSetupLink(policyID)));
Navigation.navigate(ROUTES.SETTINGS_2FA_ROOT.getRoute(ROUTES.POLICY_ACCOUNTING.getRoute(policyID), getXeroSetupLink(policyID)));
}}
onCancel={() => setIsRequire2FAModalOpen(false)}
isVisible={isRequire2FAModalOpen}
Expand Down
6 changes: 3 additions & 3 deletions src/components/ConnectToXeroFlow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import useEnvironment from '@hooks/useEnvironment';
import useLocalize from '@hooks/useLocalize';
import {getXeroSetupLink} from '@libs/actions/connections/Xero';
import Navigation from '@libs/Navigation/Navigation';
import * as Link from '@userActions/Link';
import {openLink} from '@userActions/Link';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {ConnectToXeroFlowProps} from './types';
Expand All @@ -24,7 +24,7 @@ function ConnectToXeroFlow({policyID}: ConnectToXeroFlowProps) {
setIsRequire2FAModalOpen(true);
return;
}
Link.openLink(getXeroSetupLink(policyID), environmentURL);
openLink(getXeroSetupLink(policyID), environmentURL);
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, []);

Expand All @@ -33,7 +33,7 @@ function ConnectToXeroFlow({policyID}: ConnectToXeroFlowProps) {
<RequireTwoFactorAuthenticationModal
onSubmit={() => {
setIsRequire2FAModalOpen(false);
Navigation.navigate(ROUTES.SETTINGS_2FA.getRoute(ROUTES.POLICY_ACCOUNTING.getRoute(policyID), getXeroSetupLink(policyID)));
Navigation.navigate(ROUTES.SETTINGS_2FA_ROOT.getRoute(ROUTES.POLICY_ACCOUNTING.getRoute(policyID), getXeroSetupLink(policyID)));
}}
onCancel={() => {
setIsRequire2FAModalOpen(false);
Expand Down
2 changes: 1 addition & 1 deletion src/components/TabSelector/TabSelectorItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function TabSelectorItem({
>
<AnimatedPressableWithFeedback
accessibilityLabel={title}
style={[styles.tabSelectorButton, styles.animatedTabBackground(isHovered, isActive, backgroundColor), styles.userSelectNone]}
style={[styles.tabSelectorButton, styles.tabBackground(isHovered, isActive, backgroundColor), styles.userSelectNone]}
wrapperStyle={[styles.flexGrow1]}
onPress={onPress}
onHoverIn={() => setIsHovered(true)}
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,7 @@ const translations = {
securityPage: {
title: 'Security options',
subtitle: 'Enable two-factor authentication to keep your account safe.',
goToSecurity: 'Go back to security page',
},
shareCodePage: {
title: 'Your code',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,7 @@ const translations = {
securityPage: {
title: 'Opciones de seguridad',
subtitle: 'Activa la autenticación de dos factores para mantener tu cuenta segura.',
goToSecurity: 'Volver a la página de seguridad',
},
shareCodePage: {
title: 'Tu código',
Expand Down
10 changes: 9 additions & 1 deletion src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@ const SettingsModalStackNavigator = createModalStackNavigator<SettingsNavigatorP
[SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_ITEMS]: () => require<ReactComponentModule>('../../../../pages/workspace/accounting/qbd/import/QuickbooksDesktopItemsPage').default,
[SCREENS.REIMBURSEMENT_ACCOUNT]: () => require<ReactComponentModule>('../../../../pages/ReimbursementAccount/ReimbursementAccountPage').default,
[SCREENS.GET_ASSISTANCE]: () => require<ReactComponentModule>('../../../../pages/GetAssistancePage').default,
[SCREENS.SETTINGS.TWO_FACTOR_AUTH]: () => require<ReactComponentModule>('../../../../pages/settings/Security/TwoFactorAuth/TwoFactorAuthPage').default,
[SCREENS.SETTINGS.REPORT_CARD_LOST_OR_DAMAGED]: () => require<ReactComponentModule>('../../../../pages/settings/Wallet/ReportCardLostPage').default,
[SCREENS.KEYBOARD_SHORTCUTS]: () => require<ReactComponentModule>('../../../../pages/KeyboardShortcutsPage').default,
[SCREENS.SETTINGS.EXIT_SURVEY.REASON]: () => require<ReactComponentModule>('../../../../pages/settings/ExitSurvey/ExitSurveyReasonPage').default,
Expand Down Expand Up @@ -613,6 +612,14 @@ const SettingsModalStackNavigator = createModalStackNavigator<SettingsNavigatorP
[SCREENS.WORKSPACE.PER_DIEM_EDIT_CURRENCY]: () => require<ReactComponentModule>('../../../../pages/workspace/perDiem/EditPerDiemCurrencyPage').default,
});

const TwoFactorAuthenticatorStackNavigator = createModalStackNavigator<EnablePaymentsNavigatorParamList>({
[SCREENS.TWO_FACTOR_AUTH.ROOT]: () => require<ReactComponentModule>('../../../../pages/settings/Security/TwoFactorAuth/TwoFactorAuthPage').default,
[SCREENS.TWO_FACTOR_AUTH.VERIFY]: () => require<ReactComponentModule>('../../../../pages/settings/Security/TwoFactorAuth/VerifyPage').default,
[SCREENS.TWO_FACTOR_AUTH.DISABLED]: () => require<ReactComponentModule>('../../../../pages/settings/Security/TwoFactorAuth/DisabledPage').default,
[SCREENS.TWO_FACTOR_AUTH.DISABLE]: () => require<ReactComponentModule>('../../../../pages/settings/Security/TwoFactorAuth/DisablePage').default,
[SCREENS.TWO_FACTOR_AUTH.SUCCESS]: () => require<ReactComponentModule>('../../../../pages/settings/Security/TwoFactorAuth/SuccessPage').default,
});

const EnablePaymentsStackNavigator = createModalStackNavigator<EnablePaymentsNavigatorParamList>({
[SCREENS.ENABLE_PAYMENTS_ROOT]: () => require<ReactComponentModule>('../../../../pages/EnablePayments/EnablePaymentsPage').default,
});
Expand Down Expand Up @@ -738,6 +745,7 @@ export {
ReportSettingsModalStackNavigator,
RoomMembersModalStackNavigator,
SettingsModalStackNavigator,
TwoFactorAuthenticatorStackNavigator,
SignInModalStackNavigator,
CategoriesModalStackNavigator,
TagsModalStackNavigator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import NoDropZone from '@components/DragAndDrop/NoDropZone';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
import {abandonReviewDuplicateTransactions} from '@libs/actions/Transaction';
import {clearTwoFactorAuthData} from '@libs/actions/TwoFactorAuthActions';
import {isSafari} from '@libs/Browser';
import hideKeyboardOnSwipe from '@libs/Navigation/AppNavigator/hideKeyboardOnSwipe';
import * as ModalStackNavigators from '@libs/Navigation/AppNavigator/ModalStackNavigators';
Expand Down Expand Up @@ -86,6 +87,15 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) {
name={SCREENS.RIGHT_MODAL.SETTINGS}
component={ModalStackNavigators.SettingsModalStackNavigator}
/>
<Stack.Screen
name={SCREENS.RIGHT_MODAL.TWO_FACTOR_AUTH}
component={ModalStackNavigators.TwoFactorAuthenticatorStackNavigator}
listeners={{
blur: () => {
InteractionManager.runAfterInteractions(clearTwoFactorAuthData);
},
}}
/>
<Stack.Screen
name={SCREENS.RIGHT_MODAL.NEW_CHAT}
component={ModalStackNavigators.NewChatModalStackNavigator}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ const CENTRAL_PANE_TO_RHP_MAPPING: Partial<Record<keyof SettingsSplitNavigatorPa
SCREENS.SETTINGS.WALLET.CARDS_DIGITAL_DETAILS_UPDATE_ADDRESS,
],
[SCREENS.SETTINGS.SECURITY]: [
SCREENS.SETTINGS.TWO_FACTOR_AUTH,
SCREENS.TWO_FACTOR_AUTH.ROOT,
SCREENS.TWO_FACTOR_AUTH.VERIFY,
SCREENS.TWO_FACTOR_AUTH.SUCCESS,
SCREENS.TWO_FACTOR_AUTH.DISABLED,
SCREENS.TWO_FACTOR_AUTH.DISABLE,
SCREENS.SETTINGS.CLOSE,
SCREENS.SETTINGS.DELEGATE.ADD_DELEGATE,
SCREENS.SETTINGS.DELEGATE.DELEGATE_ROLE,
Expand Down
28 changes: 24 additions & 4 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,6 @@ const config: LinkingOptions<RootNavigatorParamList>['config'] = {
path: ROUTES.SETTINGS_ADDRESS_STATE.route,
exact: true,
},
[SCREENS.SETTINGS.TWO_FACTOR_AUTH]: {
path: ROUTES.SETTINGS_2FA.route,
exact: true,
},
[SCREENS.SETTINGS.DELEGATE.ADD_DELEGATE]: {
path: ROUTES.SETTINGS_ADD_DELEGATE,
exact: true,
Expand Down Expand Up @@ -978,6 +974,30 @@ const config: LinkingOptions<RootNavigatorParamList>['config'] = {
},
},
},
[SCREENS.RIGHT_MODAL.TWO_FACTOR_AUTH]: {
screens: {
[SCREENS.TWO_FACTOR_AUTH.ROOT]: {
path: ROUTES.SETTINGS_2FA_ROOT.route,
exact: true,
},
[SCREENS.TWO_FACTOR_AUTH.VERIFY]: {
path: ROUTES.SETTINGS_2FA_VERIFY.route,
exact: true,
},
[SCREENS.TWO_FACTOR_AUTH.SUCCESS]: {
path: ROUTES.SETTINGS_2FA_SUCCESS.route,
exact: true,
},
[SCREENS.TWO_FACTOR_AUTH.DISABLED]: {
path: ROUTES.SETTINGS_2FA_DISABLED,
exact: true,
},
[SCREENS.TWO_FACTOR_AUTH.DISABLE]: {
path: ROUTES.SETTINGS_2FA_DISABLE,
exact: true,
},
},
},
[SCREENS.RIGHT_MODAL.PRIVATE_NOTES]: {
screens: {
[SCREENS.PRIVATE_NOTES.LIST]: ROUTES.PRIVATE_NOTES_LIST.route,
Expand Down
Loading

0 comments on commit ac3b408

Please sign in to comment.