From dbc420472c7fa369bbbafc85fa4e929301ad45db Mon Sep 17 00:00:00 2001 From: Aswin S Date: Mon, 5 Feb 2024 21:00:06 +0530 Subject: [PATCH 1/2] fix: wait for navigation ready state before signing in --- src/pages/ValidateLoginPage/index.tsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/pages/ValidateLoginPage/index.tsx b/src/pages/ValidateLoginPage/index.tsx index 7e79216a129d..61bfce040bfb 100644 --- a/src/pages/ValidateLoginPage/index.tsx +++ b/src/pages/ValidateLoginPage/index.tsx @@ -13,13 +13,16 @@ function ValidateLoginPage({ session, }: ValidateLoginPageProps) { useEffect(() => { - if (session?.authToken) { - // If already signed in, do not show the validate code if not on web, - // because we don't want to block the user with the interstitial page. - Navigation.goBack(); - } else { - Session.signInWithValidateCodeAndNavigate(Number(accountID), validateCode); - } + // Wait till navigation becomes available + Navigation.isNavigationReady().then(() => { + if (session?.authToken) { + // If already signed in, do not show the validate code if not on web, + // because we don't want to block the user with the interstitial page. + Navigation.goBack(); + } else { + Session.signInWithValidateCodeAndNavigate(Number(accountID), validateCode); + } + }); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); From 484116c267c7c97384d9282207316806f7afa7fc Mon Sep 17 00:00:00 2001 From: Aswin S Date: Mon, 5 Feb 2024 23:21:54 +0530 Subject: [PATCH 2/2] fix: redirect to signin page on validation failure --- src/pages/ValidateLoginPage/index.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/pages/ValidateLoginPage/index.tsx b/src/pages/ValidateLoginPage/index.tsx index 61bfce040bfb..5415c359aab0 100644 --- a/src/pages/ValidateLoginPage/index.tsx +++ b/src/pages/ValidateLoginPage/index.tsx @@ -3,6 +3,7 @@ import {withOnyx} from 'react-native-onyx'; import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; import Navigation from '@libs/Navigation/Navigation'; import * as Session from '@userActions/Session'; +import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {ValidateLoginPageOnyxNativeProps, ValidateLoginPageProps} from './types'; @@ -26,6 +27,16 @@ function ValidateLoginPage({ // eslint-disable-next-line react-hooks/exhaustive-deps }, []); + useEffect(() => { + if (session?.autoAuthState !== CONST.AUTO_AUTH_STATE.FAILED) { + return; + } + // Go back to initial route if validation fails + Navigation.isNavigationReady().then(() => { + Navigation.goBack(); + }); + }, [session?.autoAuthState]); + return ; }