Skip to content

Commit b3cc3b4

Browse files
committed
fixed the signout issue
1 parent 9de01b3 commit b3cc3b4

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/contexts/AuthContext.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,19 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
4848
useEffect(() => {
4949
// Set up the auth state listener first
5050
const { data: { subscription } } = supabase.auth.onAuthStateChange(
51-
async (event, currentSession) => {
51+
(event, currentSession) => {
5252
setSession(currentSession);
5353
setUser(currentSession?.user ?? null);
5454

55-
if (currentSession?.user) {
55+
setTimeout(async()=>{
56+
if (currentSession?.user) {
5657
// Fetch user role when user is signed in
5758
const role = await fetchUserRole(currentSession.user.id);
5859
setUserRole(role);
5960
} else {
6061
// Clear user role when user is signed out
6162
setUserRole(null);
6263
}
63-
6464
// Handle events
6565
if (event === 'SIGNED_IN') {
6666
toast({
@@ -73,6 +73,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
7373
description: "You have been signed out successfully.",
7474
});
7575
}
76+
},0);
7677
}
7778
);
7879

0 commit comments

Comments
 (0)