Skip to content

Commit 06662fa

Browse files
authored
Merge pull request #32245 from AmjedNazzal/Issue31789
2 parents 9d2ea87 + eb1207f commit 06662fa

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

src/libs/SessionUtils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ Onyx.connect({
3535
if (loggedInDuringSession) {
3636
return;
3737
}
38-
39-
if (session?.authToken) {
38+
// We are incorporating a check for 'signedInWithShortLivedAuthToken' to handle cases where login is performed using a ShortLivedAuthToken
39+
// This check is necessary because, with ShortLivedAuthToken, 'authToken' gets populated, leading to 'loggedInDuringSession' being assigned a false value
40+
if (session?.authToken && !session?.signedInWithShortLivedAuthToken) {
4041
loggedInDuringSession = false;
4142
} else {
4243
loggedInDuringSession = true;

src/libs/actions/Session/index.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -339,28 +339,38 @@ function signInWithShortLivedAuthToken(email: string, authToken: string) {
339339
isLoading: true,
340340
},
341341
},
342-
];
343-
344-
const successData: OnyxUpdate[] = [
342+
// We are making a temporary modification to 'signedInWithShortLivedAuthToken' to ensure that 'App.openApp' will be called at least once
345343
{
346344
onyxMethod: Onyx.METHOD.MERGE,
347-
key: ONYXKEYS.ACCOUNT,
345+
key: ONYXKEYS.SESSION,
348346
value: {
349-
isLoading: false,
347+
signedInWithShortLivedAuthToken: true,
350348
},
351349
},
352350
];
353351

354-
const failureData: OnyxUpdate[] = [
352+
// Subsequently, we revert it back to the default value of 'signedInWithShortLivedAuthToken' in 'successData' or 'failureData' to ensure the user is logged out on refresh
353+
// We are combining both success and failure data params into one const as they are identical
354+
const resolutionData: OnyxUpdate[] = [
355355
{
356356
onyxMethod: Onyx.METHOD.MERGE,
357357
key: ONYXKEYS.ACCOUNT,
358358
value: {
359359
isLoading: false,
360360
},
361361
},
362+
{
363+
onyxMethod: Onyx.METHOD.MERGE,
364+
key: ONYXKEYS.SESSION,
365+
value: {
366+
signedInWithShortLivedAuthToken: null,
367+
},
368+
},
362369
];
363370

371+
const successData = resolutionData;
372+
const failureData = resolutionData;
373+
364374
// 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.
365375
// scene 1: the user is transitioning to newDot from a different account on oldDot.
366376
// scene 2: the user is transitioning to desktop app from a different account on web app.

src/types/onyx/Session.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ type Session = {
2727

2828
/** Server side errors keyed by microtime */
2929
errors?: OnyxCommon.Errors;
30+
31+
/** User signed in with short lived token */
32+
signedInWithShortLivedAuthToken?: boolean;
3033
};
3134

3235
export default Session;

0 commit comments

Comments
 (0)