Skip to content
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
6 changes: 4 additions & 2 deletions src/libs/actions/Session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ function signOutAndRedirectToSignIn(shouldResetToHome?: boolean, shouldStashSess
Log.info('No stashed session found, clearing the session');
}

const isPerformingSupportalLogout = isSupportal && shouldRestoreStashedSession && !shouldStashSession;

// Wait for signOut (if called), then redirect and update Onyx.
return signOutPromise
.then((response) => {
Expand All @@ -378,7 +380,7 @@ function signOutAndRedirectToSignIn(shouldResetToHome?: boolean, shouldStashSess
true,
true,
);
} else if (shouldRestoreStashedSession && !shouldStashSession && hasStashedSession()) {
} else if (isPerformingSupportalLogout && hasStashedSession()) {
// We have confirmed here that the supportal agent was logged in, so we can restore the stashed session
// and then redirect to the oldDot supportal page to restore the stashed session
// Clear the Onyx DB of stale data that might be present from a previous session
Expand All @@ -391,7 +393,7 @@ function signOutAndRedirectToSignIn(shouldResetToHome?: boolean, shouldStashSess
});
});
});
} else if (shouldRestoreStashedSession && !shouldStashSession && !hasStashedSession()) {
} else if (isPerformingSupportalLogout && !hasStashedSession()) {
// If the supportal agent was not logged in, we call `redirectToSignIn` to clear the Onyx DB
// and then redirect to supportal and restore the stashed session
redirectToSignIn().then(() => {
Expand Down
1 change: 1 addition & 0 deletions tests/actions/SessionTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ describe('Session', () => {

await Onyx.set(ONYXKEYS.STASHED_CREDENTIALS, testStashedCredentials);
await Onyx.set(ONYXKEYS.STASHED_SESSION, testStashedSession);
await Onyx.merge(ONYXKEYS.SESSION, {authTokenType: CONST.AUTH_TOKEN_TYPES.SUPPORT});

await waitForBatchedUpdates();

Expand Down
Loading