Skip to content

Commit dc97ffc

Browse files
authored
Merge pull request #281 from rupato-deriv/Rupato/Fix-oidc-isclient-populated-check
fix: added isclient check
2 parents 7be367c + 602ab80 commit dc97ffc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/components/layout/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ const Layout = () => {
2121
const checkClientAccount = JSON.parse(localStorage.getItem('clientAccounts') ?? '{}');
2222
const getQueryParams = new URLSearchParams(window.location.search);
2323
const currency = getQueryParams.get('account') ?? '';
24+
const clientAccounts = JSON.parse(localStorage.getItem('accountsList') ?? '{}');
25+
const isClientAccountsPopulated = Object.keys(clientAccounts).length > 0;
26+
2427
const ifClientAccountHasCurrency =
2528
Object.values(checkClientAccount).some(account => account.currency === currency) || currency === 'demo';
2629

@@ -31,13 +34,12 @@ const Layout = () => {
3134
});
3235

3336
useEffect(() => {
34-
if (isLoggedInCookie && isOAuth2Enabled && !isEndpointPage && !isCallbackPage) {
35-
console.log('requestOidcAuthentication');
37+
if (isLoggedInCookie && !isClientAccountsPopulated && isOAuth2Enabled && !isEndpointPage && !isCallbackPage) {
3638
requestOidcAuthentication({
3739
redirectCallbackUri: `${window.location.origin}/callback`,
3840
});
3941
}
40-
}, [isLoggedInCookie, isOAuth2Enabled, isEndpointPage, isCallbackPage]);
42+
}, [isLoggedInCookie, isClientAccountsPopulated, isOAuth2Enabled, isEndpointPage, isCallbackPage]);
4143

4244
return (
4345
<div className={clsx('layout', { responsive: isDesktop })}>

0 commit comments

Comments
 (0)