diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.js b/src/libs/Navigation/AppNavigator/AuthScreens.js index a4d934faec4..dd7175dbc6f 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.js +++ b/src/libs/Navigation/AppNavigator/AuthScreens.js @@ -35,6 +35,7 @@ import * as SessionUtils from '../../SessionUtils'; import NotFoundPage from '../../../pages/ErrorPage/NotFoundPage'; import getRootNavigatorScreenOptions from './getRootNavigatorScreenOptions'; import DemoSetupPage from '../../../pages/DemoSetupPage'; +import getCurrentUrl from '../currentUrl'; let timezone; let currentAccountID; @@ -145,6 +146,15 @@ class AuthScreens extends React.Component { } componentDidMount() { + const currentUrl = getCurrentUrl(); + const isLoggingInAsNewUser = SessionUtils.isLoggingInAsNewUser(currentUrl, this.props.session.email); + // Sign out the current user if we're transitioning with a different user + const isTransitioning = currentUrl.includes(ROUTES.TRANSITION_BETWEEN_APPS); + if (isLoggingInAsNewUser && isTransitioning) { + Session.signOutAndRedirectToSignIn(); + return; + } + NetworkConnection.listenForReconnect(); NetworkConnection.onReconnect(() => { if (isLoadingApp) { diff --git a/src/libs/actions/App.js b/src/libs/actions/App.js index a1d64154906..83bbe175978 100644 --- a/src/libs/actions/App.js +++ b/src/libs/actions/App.js @@ -389,9 +389,6 @@ function setUpPoliciesAndNavigate(session, shouldNavigateToAdminChat) { // Sign out the current user if we're transitioning with a different user const isTransitioning = Str.startsWith(url.pathname, Str.normalizeUrl(ROUTES.TRANSITION_BETWEEN_APPS)); - if (isLoggingInAsNewUser && isTransitioning) { - Session.signOut(); - } const shouldCreateFreePolicy = !isLoggingInAsNewUser && isTransitioning && exitTo === ROUTES.WORKSPACE_NEW; if (shouldCreateFreePolicy) {