Skip to content

Commit 65c576f

Browse files
committed
Listening for session expiry/logout event.
1 parent 8fb021d commit 65c576f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

demos/react-supabase-todolist/src/app/router.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ const AuthGuard = ({ children }: AuthGuardProps) => {
2828
console.error(`No Supabase connector has been created yet.`);
2929
return;
3030
}
31+
32+
connector.client.auth.onAuthStateChange(async (event, _session) => {
33+
if (event === 'SIGNED_OUT') {
34+
console.log("here");
35+
navigate(LOGIN_ROUTE);
36+
}
37+
});
38+
3139
const loginGuard = () => {
3240
if (!connector.currentSession) {
3341
navigate(LOGIN_ROUTE);

0 commit comments

Comments
 (0)