File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments