Skip to content

Commit

Permalink
fix error when open sign in modal
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanDylann committed Oct 20, 2023
1 parent 0ac3e98 commit ce65315
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import * as Url from '../../../libs/Url';
import ROUTES from '../../../ROUTES';
import tryResolveUrlFromApiRoot from '../../../libs/tryResolveUrlFromApiRoot';
import useEnvironment from '../../../hooks/useEnvironment';
import * as Session from '../../../libs/actions/Session';

function AnchorRenderer(props) {
const htmlAttribs = props.tnode.attributes;
Expand Down Expand Up @@ -52,6 +53,10 @@ function AnchorRenderer(props) {
// 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
// instead of in a new tab or with a page refresh (which is the default behavior of an anchor tag)
if (internalNewExpensifyPath && hasSameOrigin) {
if (Session.isAnonymousUser() && !Session.canAccessRouteByAnonymousUser(internalNewExpensifyPath)) {
Session.signOutAndRedirectToSignIn();
return;
}
Navigation.navigate(internalNewExpensifyPath);
return;
}
Expand Down
8 changes: 0 additions & 8 deletions src/libs/Navigation/NavigationRoot.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import StatusBar from '../StatusBar';
import useCurrentReportID from '../../hooks/useCurrentReportID';
import useWindowDimensions from '../../hooks/useWindowDimensions';
import {SidebarNavigationContext} from '../../pages/home/sidebar/SidebarNavigationContext';
import * as Session from '../actions/Session';
import getCurrentUrl from './currentUrl';
import ROUTES from '../../ROUTES';

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

// Update the global navigation to show the correct selected menu items.
globalNavigation.updateFromNavigationState(state);

const route = Navigation.getActiveRoute();
if (Session.isAnonymousUser() && !Session.canAccessRouteByAnonymousUser(route) && !getCurrentUrl().includes(ROUTES.SIGN_IN_MODAL)) {
Session.signOutAndRedirectToSignIn();
}
};

return (
Expand Down
8 changes: 7 additions & 1 deletion src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -1909,7 +1909,13 @@ function openReportFromDeepLink(url, isAuthenticated) {
InteractionManager.runAfterInteractions(() => {
Session.waitForUserSignIn().then(() => {
if (route === ROUTES.CONCIERGE) {
navigateToConciergeChat(true);
navigateToConciergeChat();
return;
}
if (Session.isAnonymousUser() && !Session.canAccessRouteByAnonymousUser(route)) {
Navigation.isNavigationReady().then(() => {
Session.signOutAndRedirectToSignIn();
});
return;
}
Navigation.navigate(route, CONST.NAVIGATION.TYPE.PUSH);
Expand Down

0 comments on commit ce65315

Please sign in to comment.