-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fix here is your magic code shows briefly when login with magic link #40766
Changes from all commits
da2ef18
b9b8e7a
4491df7
3a694d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,9 +24,11 @@ function ValidateLoginPage({ | |
const isSignedIn = !!session?.authToken && session?.authTokenType !== CONST.AUTH_TOKEN_TYPES.ANONYMOUS; | ||
const is2FARequired = !!account?.requiresTwoFactorAuth; | ||
const cachedAccountID = credentials?.accountID; | ||
const isUserClickedSignIn = !login && isSignedIn && (autoAuthState === CONST.AUTO_AUTH_STATE.SIGNING_IN || autoAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN); | ||
const shouldStartSignInWithValidateCode = !isUserClickedSignIn && !isSignedIn && (!!login || !!exitTo); | ||
|
||
useEffect(() => { | ||
if (!login && isSignedIn && (autoAuthState === CONST.AUTO_AUTH_STATE.SIGNING_IN || autoAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN)) { | ||
if (isUserClickedSignIn) { | ||
// The user clicked the option to sign in the current tab | ||
Navigation.isNavigationReady().then(() => { | ||
Navigation.goBack(); | ||
|
@@ -35,7 +37,7 @@ function ValidateLoginPage({ | |
} | ||
Session.initAutoAuthState(autoAuthState); | ||
|
||
if (isSignedIn || (!login && !exitTo)) { | ||
if (!shouldStartSignInWithValidateCode) { | ||
if (exitTo) { | ||
Session.handleExitToNavigation(exitTo); | ||
} | ||
|
@@ -71,13 +73,14 @@ function ValidateLoginPage({ | |
{autoAuthState === CONST.AUTO_AUTH_STATE.FAILED && <ExpiredValidateCodeModal />} | ||
{autoAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN && is2FARequired && !isSignedIn && <JustSignedInModal is2FARequired />} | ||
{autoAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN && isSignedIn && !exitTo && <JustSignedInModal is2FARequired={false} />} | ||
{autoAuthState === CONST.AUTO_AUTH_STATE.NOT_STARTED && !exitTo && ( | ||
{/* If session.autoAuthState isn't available yet, we use shouldStartSignInWithValidateCode to conditionally render the component instead of local autoAuthState which contains a default value of NOT_STARTED */} | ||
{(!session?.autoAuthState ? !shouldStartSignInWithValidateCode : autoAuthState === CONST.AUTO_AUTH_STATE.NOT_STARTED) && !exitTo && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it goes back to the main thing where we assign a default value when session?.autoAuthState is not present at line 23. How can we simplify this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, it's similar but not the same. I can only simplify the 2nd condition to, but I decided to write it like above so it's consistent with the first condition and align with the comment |
||
<ValidateCodeModal | ||
accountID={Number(accountID)} | ||
code={validateCode} | ||
/> | ||
)} | ||
{autoAuthState === CONST.AUTO_AUTH_STATE.SIGNING_IN && <FullScreenLoadingIndicator />} | ||
{(!session?.autoAuthState ? shouldStartSignInWithValidateCode : autoAuthState === CONST.AUTO_AUTH_STATE.SIGNING_IN) && <FullScreenLoadingIndicator />} | ||
</> | ||
); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's commented here or which part do you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good. I asked to explain all the checks happening on this component. It's confusing for me.
e.g When this......... happens, we show ......and do ......
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think that would be tricky since I'm not the one who added the condition and I agree the condition is confusing, so I don't know for example why we need to check for
!exitTo
.App/src/pages/ValidateLoginPage/index.website.tsx
Line 73 in e8ae3c5