Skip to content

Commit

Permalink
Merge pull request #4614 from kidroca/kidroca/redirectToSignIn-clear-…
Browse files Browse the repository at this point in the history
…storage-fix

Clear storage immediately on sign out
  • Loading branch information
francoisl authored Aug 12, 2021
2 parents 8b3b629 + 72bf6c0 commit 3f72e03
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/libs/actions/SignInRedirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,18 @@ function redirectToSignIn(errorMessage) {
const activeClients = currentActiveClients;
const preferredLocale = currentPreferredLocale;

// We must set the authToken to null so we can navigate to "signin" it's not possible to navigate to the route as
// it only exists when the authToken is null.
Onyx.set(ONYXKEYS.SESSION, {authToken: null})
// Clearing storage discards the authToken. This causes a redirect to the SignIn screen
Onyx.clear()
.then(() => {
Onyx.clear().then(() => {
if (preferredLocale) {
Onyx.set(ONYXKEYS.NVP_PREFERRED_LOCALE, preferredLocale);
}
if (errorMessage) {
Onyx.set(ONYXKEYS.SESSION, {error: errorMessage});
}
if (activeClients && activeClients.length > 0) {
Onyx.set(ONYXKEYS.ACTIVE_CLIENTS, activeClients);
}
});
if (preferredLocale) {
Onyx.set(ONYXKEYS.NVP_PREFERRED_LOCALE, preferredLocale);
}
if (errorMessage) {
Onyx.set(ONYXKEYS.SESSION, {error: errorMessage});
}
if (activeClients && activeClients.length > 0) {
Onyx.set(ONYXKEYS.ACTIVE_CLIENTS, activeClients);
}
});
}

Expand Down

0 comments on commit 3f72e03

Please sign in to comment.