From 7108729a80edc464ed73d67c30743d86afd9881a Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Wed, 6 Aug 2025 00:13:24 +0000 Subject: [PATCH] Add Supabase configuration check in AuthContext cgen-bd43561f1b244b20b69dc5c27a2c9be9 --- client/contexts/AuthContext.tsx | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/client/contexts/AuthContext.tsx b/client/contexts/AuthContext.tsx index b6a72559..118fc6fe 100644 --- a/client/contexts/AuthContext.tsx +++ b/client/contexts/AuthContext.tsx @@ -32,6 +32,13 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children const [loading, setLoading] = useState(true); useEffect(() => { + // Check if Supabase is configured + if (!isSupabaseConfigured) { + console.warn('Supabase is not configured. Please set up your environment variables.'); + setLoading(false); + return; + } + // Get initial session supabase.auth.getSession().then(({ data: { session } }) => { setSession(session); @@ -40,6 +47,9 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children fetchUserProfile(session.user.id); } setLoading(false); + }).catch((error) => { + console.error('Error getting session:', error); + setLoading(false); }); // Listen for auth changes @@ -48,7 +58,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children } = supabase.auth.onAuthStateChange(async (event, session) => { setSession(session); setUser(session?.user ?? null); - + if (session?.user) { await fetchUserProfile(session.user.id); } else { @@ -58,14 +68,14 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children // Show toast notifications for auth events if (event === 'SIGNED_IN') { - aethexToast.success({ - title: 'Welcome back!', - description: 'Successfully signed in to AeThex OS' + aethexToast.success({ + title: 'Welcome back!', + description: 'Successfully signed in to AeThex OS' }); } else if (event === 'SIGNED_OUT') { - aethexToast.info({ - title: 'Signed out', - description: 'Come back soon!' + aethexToast.info({ + title: 'Signed out', + description: 'Come back soon!' }); } });