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

Fix - Workspace - Currencies do not load after transition from OldDot when other user logged in ND #31789 #32245

Merged
merged 11 commits into from
Dec 14, 2023
5 changes: 3 additions & 2 deletions src/libs/SessionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ Onyx.connect({
if (loggedInDuringSession) {
return;
}

if (session?.authToken) {
// We are incorporating a check for 'signedInWithShortLivedAuthToken' to handle cases where login is performed using a ShortLivedAuthToken
// This check is necessary because, with ShortLivedAuthToken, 'authToken' gets populated, leading to 'loggedInDuringSession' being assigned a false value
if (session?.authToken && !session?.signedInWithShortLivedAuthToken) {
loggedInDuringSession = false;
} else {
loggedInDuringSession = true;
Expand Down
23 changes: 23 additions & 0 deletions src/libs/actions/Session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,17 @@ function signInWithShortLivedAuthToken(email: string, authToken: string) {
isLoading: true,
},
},
// We are making a temporary modification to 'signedInWithShortLivedAuthToken' to ensure that 'App.openApp' will be called at least once
AmjedNazzal marked this conversation as resolved.
Show resolved Hide resolved
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.SESSION,
value: {
signedInWithShortLivedAuthToken: true,
},
},
];

// Subsequently, we revert it back to the default value of signedInWithShortLivedAuthToken (undefined) in 'successData' to ensure the user is logged out on refresh
const successData: OnyxUpdate[] = [
AmjedNazzal marked this conversation as resolved.
Show resolved Hide resolved
{
onyxMethod: Onyx.METHOD.MERGE,
Expand All @@ -341,6 +350,13 @@ function signInWithShortLivedAuthToken(email: string, authToken: string) {
isLoading: false,
},
},
{
AmjedNazzal marked this conversation as resolved.
Show resolved Hide resolved
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.SESSION,
value: {
signedInWithShortLivedAuthToken: undefined,
},
},
];

const failureData: OnyxUpdate[] = [
AmjedNazzal marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -351,6 +367,13 @@ function signInWithShortLivedAuthToken(email: string, authToken: string) {
isLoading: false,
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.SESSION,
value: {
signedInWithShortLivedAuthToken: undefined,
},
},
];

// If the user is signing in with a different account from the current app, should not pass the auto-generated login as it may be tied to the old account.
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/Session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ type Session = {

/** Server side errors keyed by microtime */
errors?: OnyxCommon.Errors;

/** User signed in with short lived token */
signedInWithShortLivedAuthToken?: boolean;
};

export default Session;
Expand Down
Loading