diff --git a/src/libs/actions/Session/index.ts b/src/libs/actions/Session/index.ts index 2cbf0090eac3..58032761774a 100644 --- a/src/libs/actions/Session/index.ts +++ b/src/libs/actions/Session/index.ts @@ -80,6 +80,33 @@ Onyx.connect({ callback: (val) => (preferredLocale = val), }); +function isSupportalToken(): boolean { + return sessionAuthTokenType === 'supportal'; +} + +/** + * Sets the SupportToken + */ +function setSupportAuthToken(supportAuthToken: string, email?: string, accountID?: number) { + if (supportAuthToken) { + Onyx.merge(ONYXKEYS.SESSION, { + authTokenType: 'supportal', + authToken: 'dummy-token-supportal-will-be-used', + supportAuthToken, + email, + accountID, + }).then(() => { + Log.info("[Supportal] Authtoken set"); + }); + } else { + Onyx.set(ONYXKEYS.SESSION, {}).then(()=> { + Log.info("[Supportal] Authtoken removed"); + }); + } + Onyx.set(ONYXKEYS.LAST_VISITED_PATH, ''); + NetworkStore.setSupportAuthToken(supportAuthToken); +} + /** * Clears the Onyx store and redirects user to the sign in page */ @@ -110,10 +137,6 @@ function signOut() { } -function isSupportalToken(): boolean { - return sessionAuthTokenType === 'supportal'; -} - /** * Checks if the account is an anonymous account. */ @@ -546,29 +569,6 @@ function invalidateAuthToken() { Onyx.merge(ONYXKEYS.SESSION, {authToken: 'pizza'}); } -/** - * Sets the SupportToken - */ -function setSupportAuthToken(supportAuthToken: string, email?: string, accountID?: number) { - if (supportAuthToken) { - Onyx.merge(ONYXKEYS.SESSION, { - authTokenType: 'supportal', - authToken: 'dummy-token-supportal-will-be-used', - supportAuthToken, - email, - accountID, - }).then(() => { - Log.info("[Supportal] Authtoken set"); - }); - } else { - Onyx.set(ONYXKEYS.SESSION, {}).then(()=> { - Log.info("[Supportal] Authtoken removed"); - }); - } - Onyx.set(ONYXKEYS.LAST_VISITED_PATH, ''); - NetworkStore.setSupportAuthToken(supportAuthToken); -} - /** * Clear the credentials and partial sign in session so the user can taken back to first Login step */