Skip to content

Commit

Permalink
test(dcellar-web-ui): add log
Browse files Browse the repository at this point in the history
  • Loading branch information
wenty22 committed Aug 7, 2023
1 parent 6776ab0 commit 0b0d892
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions apps/dcellar-web-ui/src/context/LoginContext/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,23 @@ export function LoginContextProvider(props: PropsWithChildren<LoginContextProvid
console.log('connector', connector)

useEffect(() => {
console.log('effect 1')
if (pathname === '/' || inline) return;

console.log('effect 2')
if (!walletAddress || loginAccount !== walletAddress) {
console.log('effect 21')
logout();
}

// Once the wallet is connected, we can get the address
// but if wallet is locked, we can't get the connector from wagmi
// to avoid errors when using the connector, we treat this situation as logout.

console.log('effect 3')
const timer = setTimeout(() => {
if (!connector) {
console.log('effect 31')
logout()
}
}, 1000)
Expand All @@ -71,9 +77,12 @@ export function LoginContextProvider(props: PropsWithChildren<LoginContextProvid
}, [walletAddress, connector, pathname, inline, loginAccount, logout])

useAsyncEffect(async () => {
console.log('async effect 1')
if (loginAccount === walletAddress) {
console.log('async effect 11')
// expire date less than 24h,remove sp auth & logout
const spMayExpired = await dispatch(checkSpOffChainMayExpired(walletAddress));
console.log('async effect 2', spMayExpired)
if (spMayExpired) logout(true);
}
}, [walletAddress]);
Expand All @@ -83,6 +92,10 @@ export function LoginContextProvider(props: PropsWithChildren<LoginContextProvid
if (!pass) {
return null;
}

if (pathname !== '/') {
return null
}

return <LoginContext.Provider value={value}>{children}</LoginContext.Provider>;
}

0 comments on commit 0b0d892

Please sign in to comment.