mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 16:31:12 -05:00
Fix authentication deadlock
This commit is contained in:
@@ -59,12 +59,15 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
// Listen for auth changes
|
||||
const {
|
||||
data: { subscription },
|
||||
} = supabase.auth.onAuthStateChange(async (event, session) => {
|
||||
} = supabase.auth.onAuthStateChange((event, session) => {
|
||||
setSession(session);
|
||||
setUser(session?.user ?? null);
|
||||
|
||||
if (session?.user) {
|
||||
await fetchProfile(session.user.id);
|
||||
// Defer profile fetch to avoid deadlock
|
||||
setTimeout(() => {
|
||||
fetchProfile(session.user.id);
|
||||
}, 0);
|
||||
} else {
|
||||
setProfile(null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user