@@ -19,27 +19,19 @@ const Layout = () => {
19
19
const isLoggedInCookie = Cookies . get ( 'logged_state' ) === 'true' ;
20
20
const isEndpointPage = window . location . pathname . includes ( 'endpoint' ) ;
21
21
const clientAccounts = JSON . parse ( localStorage . getItem ( 'accountsList' ) ?? '{}' ) ;
22
- const isClientAccountsPopulated = Object . keys ( clientAccounts ) . length > 0 ;
23
- const clientAccountsMissingToken =
24
- isClientAccountsPopulated &&
25
- Object . values ( clientAccounts ) . some ( account => ! ( account as { token ?: string } ) . token ) ;
22
+ const checkClientAccount = JSON . parse ( localStorage . getItem ( 'clientAccounts' ) ?? '{}' ) ;
23
+ const checkAccountList = JSON . parse ( localStorage . getItem ( 'accountList' ) ?? '{}' ) ;
24
+ const AccountLengthsEqual = JSON . stringify ( clientAccounts ) === JSON . stringify ( checkClientAccount ) ;
26
25
27
- console . log ( 'clientAccounts' , clientAccountsMissingToken , clientAccounts ) ;
26
+ console . log ( 'clientAccounts' , { checkClientAccount , checkAccountList , AccountLengthsEqual } ) ;
28
27
useEffect ( ( ) => {
29
- if ( isLoggedInCookie && isOAuth2Enabled && ! isEndpointPage && ! isCallbackPage && clientAccountsMissingToken ) {
28
+ if ( isLoggedInCookie && isOAuth2Enabled && ! isEndpointPage && ! isCallbackPage && ! AccountLengthsEqual ) {
30
29
console . log ( 'requestOidcAuthentication' ) ;
31
30
requestOidcAuthentication ( {
32
31
redirectCallbackUri : `${ window . location . origin } /callback` ,
33
32
} ) ;
34
33
}
35
- } , [
36
- isLoggedInCookie ,
37
- isClientAccountsPopulated ,
38
- isOAuth2Enabled ,
39
- isEndpointPage ,
40
- isCallbackPage ,
41
- clientAccountsMissingToken ,
42
- ] ) ;
34
+ } , [ isLoggedInCookie , isOAuth2Enabled , isEndpointPage , isCallbackPage ] ) ;
43
35
44
36
return (
45
37
< div className = { clsx ( 'layout' , { responsive : isDesktop } ) } >
0 commit comments