Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions src/pages/ValidateLoginPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -13,16 +14,29 @@ function ValidateLoginPage({
session,
}: ValidateLoginPageProps<ValidateLoginPageOnyxNativeProps>) {
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
}, []);

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]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were you able to find the root cause? How come it used to work before?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is because of navigation refactor. User should be redirected back to sign-in page if code validation fails.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's from navigation refactor. But wanted to know exactly which code caused this.
This file was not changed recently


return <FullScreenLoadingIndicator />;
}

Expand Down