From adefe127eeed8409937fb1deccb40f43026aed08 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Wed, 6 Aug 2025 00:32:04 +0000 Subject: [PATCH] Add OAuth sign-in method to AuthContext cgen-1e41a31a8c764e05a4b9b1ef88a3f9e1 --- client/contexts/AuthContext.tsx | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/client/contexts/AuthContext.tsx b/client/contexts/AuthContext.tsx index 9c7d91e1..9cd83137 100644 --- a/client/contexts/AuthContext.tsx +++ b/client/contexts/AuthContext.tsx @@ -171,6 +171,38 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children } }; + const signInWithOAuth = async (provider: 'github' | 'google') => { + if (!isSupabaseConfigured) { + aethexToast.warning({ + title: 'Demo Mode', + description: 'OAuth login requires Supabase to be configured. Currently in demo mode.' + }); + return; + } + + try { + const { data, error } = await supabase.auth.signInWithOAuth({ + provider, + options: { + redirectTo: `${window.location.origin}/dashboard`, + }, + }); + + if (error) throw error; + + aethexToast.success({ + title: 'Redirecting...', + description: `Signing in with ${provider}` + }); + } catch (error: any) { + aethexToast.error({ + title: `${provider} sign in failed`, + description: error.message + }); + throw error; + } + }; + const signOut = async () => { if (!isSupabaseConfigured) { setUser(null);