diff --git a/packages/manager/src/OAuth/oauth.ts b/packages/manager/src/OAuth/oauth.ts index 3d111dbecbe..3c87cedaf3a 100644 --- a/packages/manager/src/OAuth/oauth.ts +++ b/packages/manager/src/OAuth/oauth.ts @@ -42,7 +42,7 @@ function clearNonceAndCodeVerifierFromLocalStorage() { storage.authentication.codeVerifier.clear(); } -function clearAllAuthDataFromLocalStorage() { +export function clearAllAuthDataFromLocalStorage() { clearNonceAndCodeVerifierFromLocalStorage(); clearAuthDataFromLocalStorage(); } diff --git a/packages/manager/src/request.tsx b/packages/manager/src/request.tsx index 247c3fc4f64..f03cb607cff 100644 --- a/packages/manager/src/request.tsx +++ b/packages/manager/src/request.tsx @@ -4,7 +4,10 @@ import { AxiosHeaders } from 'axios'; import { ACCESS_TOKEN, API_ROOT, DEFAULT_ERROR_MESSAGE } from 'src/constants'; import { setErrors } from 'src/store/globalErrors/globalErrors.actions'; -import { clearAuthDataFromLocalStorage, redirectToLogin } from './OAuth/oauth'; +import { + clearAllAuthDataFromLocalStorage, + redirectToLogin, +} from './OAuth/oauth'; import { getEnvLocalStorageOverrides, storage } from './utilities/storage'; import type { ApplicationStore } from './store'; @@ -33,7 +36,7 @@ export type LinodeError = { errors: APIError[] }; */ let isRedirectingToLogin = false; -export const handleError = ( +export const handleError = async ( error: AxiosError, store: ApplicationStore ) => { @@ -45,8 +48,8 @@ export const handleError = ( window.location.pathname !== '/oauth/callback' ) { isRedirectingToLogin = true; - clearAuthDataFromLocalStorage(); - redirectToLogin(); + clearAllAuthDataFromLocalStorage(); + await redirectToLogin(); } const status: number = error.response?.status ?? 0;