Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desktop - Login - Unable to enter the 2FA code or exit the screen #38142

Merged
merged 5 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
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
16 changes: 16 additions & 0 deletions src/libs/desktopLoginRedirect/index.desktop.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Navigation from '@libs/Navigation/Navigation';
import CONST from '@src/CONST';
import type {AutoAuthState} from '@src/types/onyx/Session';

function desktopLoginRedirect(autoAuthState: AutoAuthState, isSignedIn: boolean) {
// NOT_STARTED - covers edge case of autoAuthState not being initialized yet (after logout)
// JUST_SIGNED_IN - confirms passing the magic code step -> we're either logged-in or shown 2FA screen
// !isSignedIn - confirms we're not signed-in yet as there's possible one last step (2FA validation)
const shouldPopToTop = (autoAuthState === CONST.AUTO_AUTH_STATE.NOT_STARTED || autoAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN) && !isSignedIn;

if (shouldPopToTop) {
Navigation.isNavigationReady().then(() => Navigation.resetToHome());
}
}

export default desktopLoginRedirect;
5 changes: 5 additions & 0 deletions src/libs/desktopLoginRedirect/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type {AutoAuthState} from '@src/types/onyx/Session';

// eslint-disable-next-line @typescript-eslint/no-unused-vars
function desktopLoginRedirect(autoAuthState: AutoAuthState, isSignedIn: boolean) {}
export default desktopLoginRedirect;
6 changes: 6 additions & 0 deletions src/pages/ValidateLoginPage/index.website.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
import ExpiredValidateCodeModal from '@components/ValidateCode/ExpiredValidateCodeModal';
import JustSignedInModal from '@components/ValidateCode/JustSignedInModal';
import ValidateCodeModal from '@components/ValidateCode/ValidateCodeModal';
import desktopLoginRedirect from '@libs/desktopLoginRedirect';
import Navigation from '@libs/Navigation/Navigation';
import * as Session from '@userActions/Session';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -43,6 +44,11 @@ function ValidateLoginPage({

// The user has initiated the sign in process on the same browser, in another tab.
Session.signInWithValidateCode(Number(accountID), validateCode);

// Since on Desktop we don't have multi-tab functionality to handle the login flow,
// we need to `popToTop` the stack after `signInWithValidateCode` in order to
// perform login for both 2FA and non-2FA accounts.
desktopLoginRedirect(autoAuthState, isSignedIn);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

Expand Down
Loading