diff options
Diffstat (limited to 'makima/frontend/src/contexts/AuthContext.tsx')
| -rw-r--r-- | makima/frontend/src/contexts/AuthContext.tsx | 27 |
1 files changed, 3 insertions, 24 deletions
diff --git a/makima/frontend/src/contexts/AuthContext.tsx b/makima/frontend/src/contexts/AuthContext.tsx index ce2724b..809c98a 100644 --- a/makima/frontend/src/contexts/AuthContext.tsx +++ b/makima/frontend/src/contexts/AuthContext.tsx @@ -6,7 +6,7 @@ import { useCallback, type ReactNode, } from "react"; -import { supabase, isAuthConfigured, type Session, type User } from "../lib/supabase"; +import { supabase, isAuthConfigured, SUPABASE_URL, type Session, type User } from "../lib/supabase"; interface AuthState { user: User | null; @@ -42,16 +42,6 @@ export function AuthProvider({ children }: { children: ReactNode }) { // Initialize auth state useEffect(() => { - if (!supabase) { - // Auth not configured - allow unauthenticated access - setState((prev) => ({ - ...prev, - isLoading: false, - isAuthenticated: true, // Allow access when auth is not configured - })); - return; - } - // Get initial session supabase.auth.getSession().then(({ data: { session } }) => { setState({ @@ -84,9 +74,6 @@ export function AuthProvider({ children }: { children: ReactNode }) { const signIn = useCallback( async (email: string, password: string): Promise<{ error: Error | null }> => { - if (!supabase) { - return { error: new Error("Auth not configured") }; - } const { error } = await supabase.auth.signInWithPassword({ email, password }); return { error: error ? new Error(error.message) : null }; }, @@ -95,9 +82,6 @@ export function AuthProvider({ children }: { children: ReactNode }) { const signUp = useCallback( async (email: string, password: string): Promise<{ error: Error | null }> => { - if (!supabase) { - return { error: new Error("Auth not configured") }; - } const { error } = await supabase.auth.signUp({ email, password }); return { error: error ? new Error(error.message) : null }; }, @@ -114,20 +98,15 @@ export function AuthProvider({ children }: { children: ReactNode }) { })); // Clear Supabase storage directly in case signOut API fails - const storageKey = `sb-${import.meta.env.VITE_SUPABASE_URL?.split('//')[1]?.split('.')[0]}-auth-token`; + const storageKey = `sb-${SUPABASE_URL.split('//')[1]?.split('.')[0]}-auth-token`; localStorage.removeItem(storageKey); // Try to call signOut API (may fail if token is invalid, that's OK) - if (supabase) { - await supabase.auth.signOut({ scope: 'local' }).catch(() => {}); - } + await supabase.auth.signOut({ scope: 'local' }).catch(() => {}); }, []); const signInWithOAuth = useCallback( async (provider: "github" | "google"): Promise<{ error: Error | null }> => { - if (!supabase) { - return { error: new Error("Auth not configured") }; - } const { error } = await supabase.auth.signInWithOAuth({ provider, options: { |
