Skip to content

Commit

Permalink
Merge pull request #274 from rupato-deriv/Fix--OIDC
Browse files Browse the repository at this point in the history
fix: removed extra check
  • Loading branch information
rupato-deriv authored Feb 18, 2025
2 parents c6bb244 + aba097f commit d5401c8
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/components/layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,19 @@ const Layout = () => {
const isLoggedInCookie = Cookies.get('logged_state') === 'true';
const isEndpointPage = window.location.pathname.includes('endpoint');
const clientAccounts = JSON.parse(localStorage.getItem('accountsList') ?? '{}');
const isClientAccountsPopulated = Object.keys(clientAccounts).length > 0;
const clientAccountsMissingToken =
isClientAccountsPopulated &&
Object.values(clientAccounts).some(account => !(account as { token?: string }).token);
const checkClientAccount = JSON.parse(localStorage.getItem('clientAccounts') ?? '{}');
const checkAccountList = JSON.parse(localStorage.getItem('accountList') ?? '{}');
const accountLengthsEqual = JSON.stringify(clientAccounts) === JSON.stringify(checkClientAccount);

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

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

0 comments on commit d5401c8

Please sign in to comment.