Skip to content

Commit

Permalink
Merge pull request #281 from rupato-deriv/Rupato/Fix-oidc-isclient-po…
Browse files Browse the repository at this point in the history
…pulated-check

fix: added isclient check
  • Loading branch information
rupato-deriv authored Feb 18, 2025
2 parents 7be367c + 602ab80 commit dc97ffc
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 dc97ffc

Please sign in to comment.