diff --git a/src/ROUTES.js b/src/ROUTES.js
index 6541bdfc2dab..f77405a30b31 100644
--- a/src/ROUTES.js
+++ b/src/ROUTES.js
@@ -207,4 +207,5 @@ export default {
isSubReportPageRoute: pathSegments.length > 2,
};
},
+ SIGN_IN_MODAL: 'sign-in-modal',
};
diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.js b/src/libs/Navigation/AppNavigator/AuthScreens.js
index 5ed1dc40f3f0..7317306cdbe6 100644
--- a/src/libs/Navigation/AppNavigator/AuthScreens.js
+++ b/src/libs/Navigation/AppNavigator/AuthScreens.js
@@ -48,6 +48,11 @@ Onyx.connect({
}
currentAccountID = val.accountID;
+ if (Navigation.isActiveRoute(ROUTES.SIGN_IN_MODAL)) {
+ // This means sign in in RHP was successful, so we can dismiss the modal and subscribe to user events
+ Navigation.dismissModal();
+ User.subscribeToUserEvents();
+ }
},
});
diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators.js b/src/libs/Navigation/AppNavigator/ModalStackNavigators.js
index 03d1a9196a4e..cd67fe1c3cc3 100644
--- a/src/libs/Navigation/AppNavigator/ModalStackNavigators.js
+++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators.js
@@ -739,6 +739,16 @@ const EditRequestStackNavigator = createModalStackNavigator([
},
]);
+const SignInModalStackNavigator = createModalStackNavigator([
+ {
+ getComponent: () => {
+ const SignInModal = require('../../../pages/signin/SignInModal').default;
+ return SignInModal;
+ },
+ name: 'SignIn_Root',
+ },
+]);
+
export {
MoneyRequestModalStackNavigator,
SplitDetailsModalStackNavigator,
@@ -760,4 +770,5 @@ export {
WalletStatementStackNavigator,
FlagCommentStackNavigator,
EditRequestStackNavigator,
+ SignInModalStackNavigator,
};
diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.js b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.js
index 53e2120f4c21..8e3f769ed13f 100644
--- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.js
+++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.js
@@ -93,6 +93,10 @@ function RightModalNavigator() {
name="EditRequest"
component={ModalStackNavigators.EditRequestStackNavigator}
/>
+
);
}
diff --git a/src/libs/Navigation/linkingConfig.js b/src/libs/Navigation/linkingConfig.js
index ae85699b844d..d1ba17536614 100644
--- a/src/libs/Navigation/linkingConfig.js
+++ b/src/libs/Navigation/linkingConfig.js
@@ -369,6 +369,11 @@ export default {
EditRequest_Currency: ROUTES.EDIT_CURRENCY_REQUEST,
},
},
+ SignIn: {
+ screens: {
+ SignIn_Root: ROUTES.SIGN_IN_MODAL,
+ },
+ },
},
},
},
diff --git a/src/libs/actions/Session/index.js b/src/libs/actions/Session/index.js
index a538291bd054..d0cd50b35404 100644
--- a/src/libs/actions/Session/index.js
+++ b/src/libs/actions/Session/index.js
@@ -89,11 +89,13 @@ function isAnonymousUser() {
}
function signOutAndRedirectToSignIn() {
- hideContextMenu(false);
- signOut();
- redirectToSignIn();
Log.info('Redirecting to Sign In because signOut() was called');
- if (isAnonymousUser()) {
+ hideContextMenu(false);
+ if (!isAnonymousUser()) {
+ signOut();
+ redirectToSignIn();
+ } else {
+ Navigation.navigate(ROUTES.SIGN_IN_MODAL);
Linking.getInitialURL().then((url) => {
const reportID = ReportUtils.getReportIDFromLink(url);
if (reportID) {
diff --git a/src/pages/signin/SignInModal.js b/src/pages/signin/SignInModal.js
new file mode 100644
index 000000000000..0cd566a47327
--- /dev/null
+++ b/src/pages/signin/SignInModal.js
@@ -0,0 +1,36 @@
+import React from 'react';
+import SignInPage from './SignInPage';
+import ScreenWrapper from '../../components/ScreenWrapper';
+import HeaderWithBackButton from '../../components/HeaderWithBackButton';
+import Navigation from '../../libs/Navigation/Navigation';
+import styles from '../../styles/styles';
+import * as Session from '../../libs/actions/Session';
+
+const propTypes = {};
+
+const defaultProps = {};
+
+function SignInModal() {
+ if (!Session.isAnonymousUser()) {
+ // Sign in in RHP is only for anonymous users
+ Navigation.isNavigationReady().then(() => {
+ Navigation.dismissModal();
+ });
+ }
+ return (
+
+ Navigation.goBack()} />
+
+
+ );
+}
+
+SignInModal.propTypes = propTypes;
+SignInModal.defaultProps = defaultProps;
+SignInModal.displayName = 'SignInModal';
+
+export default SignInModal;
diff --git a/src/pages/signin/SignInPage.js b/src/pages/signin/SignInPage.js
index cc5b55291940..6d846d872828 100644
--- a/src/pages/signin/SignInPage.js
+++ b/src/pages/signin/SignInPage.js
@@ -46,6 +46,9 @@ const propTypes = {
validateCode: PropTypes.string,
}),
+ /** Whether or not the sign in page is being rendered in the RHP modal */
+ isInModal: PropTypes.bool,
+
/** Override the green headline copy */
customHeadline: PropTypes.string,
};
@@ -53,6 +56,7 @@ const propTypes = {
const defaultProps = {
account: {},
credentials: {},
+ isInModal: false,
customHeadline: '',
};
@@ -81,9 +85,10 @@ function getRenderOptions({hasLogin, hasValidateCode, hasAccount, isPrimaryLogin
};
}
-function SignInPage({credentials, account, customHeadline}) {
+function SignInPage({credentials, account, isInModal, customHeadline}) {
const {translate, formatPhoneNumber} = useLocalize();
const {isSmallScreenWidth} = useWindowDimensions();
+ const shouldShowSmallScreen = isSmallScreenWidth || isInModal;
const safeAreaInsets = useSafeAreaInsets();
useEffect(() => Performance.measureTTI(), []);
@@ -119,19 +124,19 @@ function SignInPage({credentials, account, customHeadline}) {
// replacing spaces with "hard spaces" to prevent breaking the number
const userLoginToDisplay = Str.isSMSLogin(userLogin) ? formatPhoneNumber(userLogin).replace(/ /g, '\u00A0') : userLogin;
if (account.validated) {
- welcomeHeader = isSmallScreenWidth ? '' : translate('welcomeText.welcomeBack');
- welcomeText = isSmallScreenWidth
+ welcomeHeader = shouldShowSmallScreen ? '' : translate('welcomeText.welcomeBack');
+ welcomeText = shouldShowSmallScreen
? `${translate('welcomeText.welcomeBack')} ${translate('welcomeText.welcomeEnterMagicCode', {login: userLoginToDisplay})}`
: translate('welcomeText.welcomeEnterMagicCode', {login: userLoginToDisplay});
} else {
- welcomeHeader = isSmallScreenWidth ? '' : translate('welcomeText.welcome');
- welcomeText = isSmallScreenWidth
+ welcomeHeader = shouldShowSmallScreen ? '' : translate('welcomeText.welcome');
+ welcomeText = shouldShowSmallScreen
? `${translate('welcomeText.welcome')} ${translate('welcomeText.newFaceEnterMagicCode', {login: userLoginToDisplay})}`
: translate('welcomeText.newFaceEnterMagicCode', {login: userLoginToDisplay});
}
}
} else if (shouldShowUnlinkLoginForm || shouldShowEmailDeliveryFailurePage) {
- welcomeHeader = isSmallScreenWidth ? headerText : translate('welcomeText.welcomeBack');
+ welcomeHeader = shouldShowSmallScreen ? headerText : translate('welcomeText.welcomeBack');
// Don't show any welcome text if we're showing the user the email delivery failed view
if (shouldShowEmailDeliveryFailurePage) {
@@ -148,8 +153,9 @@ function SignInPage({credentials, account, customHeadline}) {
{/* LoginForm must use the isVisible prop. This keeps it mounted, but visually hidden
diff --git a/src/pages/signin/SignInPageLayout/index.js b/src/pages/signin/SignInPageLayout/index.js
index 26b7716627cd..72008d64c3c6 100644
--- a/src/pages/signin/SignInPageLayout/index.js
+++ b/src/pages/signin/SignInPageLayout/index.js
@@ -35,6 +35,9 @@ const propTypes = {
/** Whether to show welcome header on a particular page */
shouldShowWelcomeHeader: PropTypes.bool.isRequired,
+ /** Whether or not the sign in page is being rendered in the RHP modal */
+ isInModal: PropTypes.bool.isRequired,
+
/** Override the green headline copy */
customHeadline: PropTypes.string,
@@ -51,11 +54,12 @@ function SignInPageLayout(props) {
const prevPreferredLocale = usePrevious(props.preferredLocale);
let containerStyles = [styles.flex1, styles.signInPageInner];
let contentContainerStyles = [styles.flex1, styles.flexRow];
+ const shouldShowSmallScreen = props.isSmallScreenWidth || props.isInModal;
// To scroll on both mobile and web, we need to set the container height manually
const containerHeight = props.windowHeight - props.insets.top - props.insets.bottom;
- if (props.isSmallScreenWidth) {
+ if (shouldShowSmallScreen) {
containerStyles = [styles.flex1];
contentContainerStyles = [styles.flex1, styles.flexColumn];
}
@@ -77,7 +81,7 @@ function SignInPageLayout(props) {
return (
- {!props.isSmallScreenWidth ? (
+ {!shouldShowSmallScreen ? (