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
22 changes: 16 additions & 6 deletions src/libs/actions/Session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,28 +332,38 @@ function signInWithShortLivedAuthToken(email: string, authToken: string) {
isLoading: true,
},
},
];

const successData: OnyxUpdate[] = [
// 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.ACCOUNT,
key: ONYXKEYS.SESSION,
value: {
isLoading: false,
signedInWithShortLivedAuthToken: true,
},
},
];

const failureData: OnyxUpdate[] = [
// Subsequently, we revert it back to the default value of 'signedInWithShortLivedAuthToken' in 'successData' or 'failureData' to ensure the user is logged out on refresh
// We are combining both success and failure data params into one const as they are identical
const resolutionData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.ACCOUNT,
value: {
isLoading: false,
},
},
{
AmjedNazzal marked this conversation as resolved.
Show resolved Hide resolved
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.SESSION,
value: {
signedInWithShortLivedAuthToken: null,
},
},
];

const successData = resolutionData;
const failureData = resolutionData;

// 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.
// scene 1: the user is transitioning to newDot from a different account on oldDot.
// scene 2: the user is transitioning to desktop app from a different account on web app.
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