Skip to content

Commit

Permalink
fix: added isclient check
Browse files Browse the repository at this point in the history
  • Loading branch information
rupato-deriv committed Feb 18, 2025
1 parent 7be367c commit 602ab80
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const Layout = () => {
const checkClientAccount = JSON.parse(localStorage.getItem('clientAccounts') ?? '{}');
const getQueryParams = new URLSearchParams(window.location.search);
const currency = getQueryParams.get('account') ?? '';
const clientAccounts = JSON.parse(localStorage.getItem('accountsList') ?? '{}');
const isClientAccountsPopulated = Object.keys(clientAccounts).length > 0;

const ifClientAccountHasCurrency =
Object.values(checkClientAccount).some(account => account.currency === currency) || currency === 'demo';

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

useEffect(() => {
if (isLoggedInCookie && isOAuth2Enabled && !isEndpointPage && !isCallbackPage) {
console.log('requestOidcAuthentication');
if (isLoggedInCookie && !isClientAccountsPopulated && isOAuth2Enabled && !isEndpointPage && !isCallbackPage) {
requestOidcAuthentication({
redirectCallbackUri: `${window.location.origin}/callback`,
});
}
}, [isLoggedInCookie, isOAuth2Enabled, isEndpointPage, isCallbackPage]);
}, [isLoggedInCookie, isClientAccountsPopulated, isOAuth2Enabled, isEndpointPage, isCallbackPage]);

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

0 comments on commit 602ab80

Please sign in to comment.