Skip to content

Commit

Permalink
app: signout backend when we detect wallet switch
Browse files Browse the repository at this point in the history
  • Loading branch information
kahkeng committed Jul 14, 2023
1 parent e6a22ce commit 47a5b9c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/utils/rainbowSIWEmod/RainbowKitSiweNextAuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,15 @@ export function RainbowKitSiweNextAuthProvider({

/* force logout if account changes */
useEffect(() => {
if (session && session.user?.name !== account) signOut({ redirect: false });
if (session && session.user?.name !== account) {
// signout on frontend first, so that we don't end up in situation
// where frontend is signed in but backend is signed out, which will
// be confusing to the user
signOut({ redirect: false });
if (getSignoutCallback) {
getSignoutCallback();
}
}
}, [account, session]);

const adapter = useMemo(
Expand Down

0 comments on commit 47a5b9c

Please sign in to comment.