Skip to content

Commit 0bac11e

Browse files
committed
fix: login land on wrong account
1 parent b116043 commit 0bac11e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/components/layout/header/header.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { useFirebaseCountriesConfig } from '@/hooks/firebase/useFirebaseCountrie
1010
import { useApiBase } from '@/hooks/useApiBase';
1111
import { useStore } from '@/hooks/useStore';
1212
import useTMB from '@/hooks/useTMB';
13-
import { handleOidcAuthFailure } from '@/utils/auth-utils';
13+
import { clearAuthData, handleOidcAuthFailure } from '@/utils/auth-utils';
1414
import { StandaloneCircleUserRegularIcon } from '@deriv/quill-icons/Standalone';
1515
import { requestOidcAuthentication } from '@deriv-com/auth-client';
1616
import { Localize, useTranslations } from '@deriv-com/translations';
@@ -138,6 +138,7 @@ const AppHeader = observer(({ isAuthenticating }: TAppHeaderProps) => {
138138
<Button
139139
tertiary
140140
onClick={async () => {
141+
clearAuthData(false);
141142
const getQueryParams = new URLSearchParams(window.location.search);
142143
const currency = getQueryParams.get('account') ?? '';
143144
const query_param_currency =

src/utils/auth-utils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ import Cookies from 'js-cookie';
66
/**
77
* Clears authentication data from local storage and reloads the page
88
*/
9-
export const clearAuthData = (): void => {
9+
export const clearAuthData = (is_reload: boolean = true): void => {
1010
localStorage.removeItem('accountsList');
1111
localStorage.removeItem('clientAccounts');
1212
localStorage.removeItem('callback_token');
1313
localStorage.removeItem('authToken');
1414
localStorage.removeItem('active_loginid');
1515
localStorage.removeItem('client.accounts');
1616
localStorage.removeItem('client.country');
17-
location.reload();
17+
if (is_reload) {
18+
location.reload();
19+
}
1820
};
1921

2022
/**

0 commit comments

Comments
 (0)