Skip to content

Commit ce65315

Browse files
committed
fix error when open sign in modal
1 parent 0ac3e98 commit ce65315

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import * as Url from '../../../libs/Url';
1515
import ROUTES from '../../../ROUTES';
1616
import tryResolveUrlFromApiRoot from '../../../libs/tryResolveUrlFromApiRoot';
1717
import useEnvironment from '../../../hooks/useEnvironment';
18+
import * as Session from '../../../libs/actions/Session';
1819

1920
function AnchorRenderer(props) {
2021
const htmlAttribs = props.tnode.attributes;
@@ -52,6 +53,10 @@ function AnchorRenderer(props) {
5253
// If we are handling a New Expensify link then we will assume this should be opened by the app internally. This ensures that the links are opened internally via react-navigation
5354
// instead of in a new tab or with a page refresh (which is the default behavior of an anchor tag)
5455
if (internalNewExpensifyPath && hasSameOrigin) {
56+
if (Session.isAnonymousUser() && !Session.canAccessRouteByAnonymousUser(internalNewExpensifyPath)) {
57+
Session.signOutAndRedirectToSignIn();
58+
return;
59+
}
5560
Navigation.navigate(internalNewExpensifyPath);
5661
return;
5762
}

src/libs/Navigation/NavigationRoot.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ import StatusBar from '../StatusBar';
1212
import useCurrentReportID from '../../hooks/useCurrentReportID';
1313
import useWindowDimensions from '../../hooks/useWindowDimensions';
1414
import {SidebarNavigationContext} from '../../pages/home/sidebar/SidebarNavigationContext';
15-
import * as Session from '../actions/Session';
16-
import getCurrentUrl from './currentUrl';
17-
import ROUTES from '../../ROUTES';
1815

1916
// https://reactnavigation.org/docs/themes
2017
const navigationTheme = {
@@ -136,11 +133,6 @@ function NavigationRoot(props) {
136133

137134
// Update the global navigation to show the correct selected menu items.
138135
globalNavigation.updateFromNavigationState(state);
139-
140-
const route = Navigation.getActiveRoute();
141-
if (Session.isAnonymousUser() && !Session.canAccessRouteByAnonymousUser(route) && !getCurrentUrl().includes(ROUTES.SIGN_IN_MODAL)) {
142-
Session.signOutAndRedirectToSignIn();
143-
}
144136
};
145137

146138
return (

src/libs/actions/Report.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1909,7 +1909,13 @@ function openReportFromDeepLink(url, isAuthenticated) {
19091909
InteractionManager.runAfterInteractions(() => {
19101910
Session.waitForUserSignIn().then(() => {
19111911
if (route === ROUTES.CONCIERGE) {
1912-
navigateToConciergeChat(true);
1912+
navigateToConciergeChat();
1913+
return;
1914+
}
1915+
if (Session.isAnonymousUser() && !Session.canAccessRouteByAnonymousUser(route)) {
1916+
Navigation.isNavigationReady().then(() => {
1917+
Session.signOutAndRedirectToSignIn();
1918+
});
19131919
return;
19141920
}
19151921
Navigation.navigate(route, CONST.NAVIGATION.TYPE.PUSH);

0 commit comments

Comments
 (0)