-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Show a fullscreen 2fa required instead of modal #58071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Beamanator
merged 11 commits into
Expensify:main
from
bernhardoj:feat/57684-improve-2fa-enablement-fllow
Mar 17, 2025
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1865b8a
show a fullscreen 2fa required instead of modal
bernhardoj 16b43a3
lint
bernhardoj 6f685a1
Merge branch 'main' into feat/57684-improve-2fa-enablement-fllow
bernhardoj 144a965
Merge branch 'main' into feat/57684-improve-2fa-enablement-fllow
bernhardoj ad3dbb1
Merge branch 'main' into feat/57684-improve-2fa-enablement-fllow
bernhardoj 7eec01d
close both 2fa rhp and required page when closing the rhp
bernhardoj 57bdd3e
lint
bernhardoj c15a8b2
Merge branch 'main' into feat/57684-improve-2fa-enablement-fllow
bernhardoj a8e8e89
remove unnecessary check
bernhardoj d9c54c0
replace inline styles
bernhardoj 67d06b5
move the var definition inside useEffect
bernhardoj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
assets/images/simple-illustrations/simple-illustration__encryption.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| import type {RouteProp} from '@react-navigation/native'; | ||
| import {findFocusedRoute, useNavigation} from '@react-navigation/native'; | ||
| import React, {memo, useEffect, useMemo, useRef} from 'react'; | ||
| import React, {memo, useEffect, useMemo, useRef, useState} from 'react'; | ||
| import type {OnyxEntry} from 'react-native-onyx'; | ||
| import Onyx, {withOnyx} from 'react-native-onyx'; | ||
| import Onyx, {useOnyx, withOnyx} from 'react-native-onyx'; | ||
| import ActiveGuidesEventListener from '@components/ActiveGuidesEventListener'; | ||
| import ActiveWorkspaceContextProvider from '@components/ActiveWorkspaceProvider'; | ||
| import ComposeProviders from '@components/ComposeProviders'; | ||
|
|
@@ -34,6 +34,7 @@ import PusherConnectionManager from '@libs/PusherConnectionManager'; | |
| import * as SessionUtils from '@libs/SessionUtils'; | ||
| import ConnectionCompletePage from '@pages/ConnectionCompletePage'; | ||
| import NotFoundPage from '@pages/ErrorPage/NotFoundPage'; | ||
| import RequireTwoFactorAuthenticationPage from '@pages/RequireTwoFactorAuthenticationPage'; | ||
| import DesktopSignInRedirectPage from '@pages/signin/DesktopSignInRedirectPage'; | ||
| import * as App from '@userActions/App'; | ||
| import * as Download from '@userActions/Download'; | ||
|
|
@@ -216,8 +217,10 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie | |
| const currentUserPersonalDetails = useCurrentUserPersonalDetails(); | ||
| const {toggleSearch} = useSearchRouterContext(); | ||
|
|
||
| const [account] = useOnyx(ONYXKEYS.ACCOUNT); | ||
| const modal = useRef<OnyxTypes.Modal>({}); | ||
| const {isOnboardingCompleted} = useOnboardingFlowRouter(); | ||
| const [shouldShowRequire2FAPage, setShouldShowRequire2FAPage] = useState(!!account?.needsTwoFactorAuthSetup && !account.requiresTwoFactorAuth); | ||
| const navigation = useNavigation(); | ||
|
|
||
| useEffect(() => { | ||
|
|
@@ -240,6 +243,20 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie | |
| }; | ||
| }, [theme]); | ||
|
|
||
| useEffect(() => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should also add a comment here for these 2 new |
||
| if (!account?.needsTwoFactorAuthSetup || !!account.requiresTwoFactorAuth || shouldShowRequire2FAPage) { | ||
| return; | ||
| } | ||
| setShouldShowRequire2FAPage(true); | ||
| }, [account?.needsTwoFactorAuthSetup, account?.requiresTwoFactorAuth, shouldShowRequire2FAPage]); | ||
|
|
||
| useEffect(() => { | ||
| if (!shouldShowRequire2FAPage) { | ||
| return; | ||
| } | ||
| Navigation.navigate(ROUTES.REQUIRE_TWO_FACTOR_AUTH); | ||
| }, [shouldShowRequire2FAPage]); | ||
|
|
||
| useEffect(() => { | ||
| const shortcutsOverviewShortcutConfig = CONST.KEYBOARD_SHORTCUTS.SHORTCUTS; | ||
| const searchShortcutConfig = CONST.KEYBOARD_SHORTCUTS.SEARCH; | ||
|
|
@@ -537,7 +554,20 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie | |
| name={NAVIGATORS.RIGHT_MODAL_NAVIGATOR} | ||
| options={rootNavigatorScreenOptions.rightModalNavigator} | ||
| component={RightModalNavigator} | ||
| listeners={modalScreenListenersWithCancelSearch} | ||
| listeners={{ | ||
| ...modalScreenListenersWithCancelSearch, | ||
| beforeRemove: () => { | ||
| modalScreenListenersWithCancelSearch.beforeRemove(); | ||
|
|
||
| // When a 2FA RHP page is closed, if the 2FA require page is visible and the user has now enabled the 2FA, then remove the 2FA require page from the navigator. | ||
| const routeParams = navigation.getState()?.routes?.at(-1)?.params; | ||
| const screen = routeParams && 'screen' in routeParams ? routeParams.screen : ''; | ||
| if (!shouldShowRequire2FAPage || !account?.requiresTwoFactorAuth || screen !== SCREENS.RIGHT_MODAL.TWO_FACTOR_AUTH) { | ||
| return; | ||
| } | ||
| setShouldShowRequire2FAPage(false); | ||
| }, | ||
| }} | ||
| /> | ||
| <RootStack.Screen | ||
| name={NAVIGATORS.LEFT_MODAL_NAVIGATOR} | ||
|
|
@@ -584,6 +614,13 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie | |
| }} | ||
| /> | ||
| )} | ||
| {shouldShowRequire2FAPage && ( | ||
| <RootStack.Screen | ||
| name={SCREENS.REQUIRE_TWO_FACTOR_AUTH} | ||
| options={{...rootNavigatorScreenOptions.fullScreen, gestureEnabled: false}} | ||
| component={RequireTwoFactorAuthenticationPage} | ||
| /> | ||
| )} | ||
| <RootStack.Screen | ||
| name={SCREENS.WORKSPACE_JOIN_USER} | ||
| options={{ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be nice to remove the
ForAdminspart of these keys since the text doesn't say anything about admins, what do y'all think?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it doesn't mention about admin, but the page will only show in a case where a workspace (connected to Xero) admin without 2FA enabled login.