Skip to content

Commit

Permalink
Merge pull request #277 from rupato-deriv/Fix-oidc-check
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 a787d52 + f844b12 commit 8116530
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/components/layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useEffect } from 'react';
import clsx from 'clsx';
import Cookies from 'js-cookie';
import { Outlet } from 'react-router-dom';
import { api_base } from '@/external/bot-skeleton';
import { useOauth2 } from '@/hooks/auth/useOauth2';
import { requestOidcAuthentication } from '@deriv-com/auth-client';
import { useDevice } from '@deriv-com/ui';
Expand All @@ -10,12 +11,6 @@ import AppHeader from './header';
import Body from './main-body';
import './layout.scss';

function hasAllKeys(obj1, obj2) {
const keys1 = Object.keys(obj1);
const keys2 = new Set(Object.keys(obj2));
return keys1.every(key => keys2.has(key));
}

const Layout = () => {
const { isDesktop } = useDevice();

Expand All @@ -26,19 +21,17 @@ const Layout = () => {
const isEndpointPage = window.location.pathname.includes('endpoint');
const checkClientAccount = JSON.parse(localStorage.getItem('clientAccounts') ?? '{}');
const checkAccountList = JSON.parse(localStorage.getItem('accountList') ?? '{}');
const cookiesAccount = JSON.parse(Cookies.get('client.accounts') ?? '{}');
const isAccountPresent = hasAllKeys(checkClientAccount, cookiesAccount);

console.log('clientAccounts', { cookiesAccount, checkClientAccount, checkAccountList, isAccountPresent });
console.log('clientAccounts', { checkClientAccount, checkAccountList, api_base });

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

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

0 comments on commit 8116530

Please sign in to comment.