Add OAuth sign-in method to AuthContext

cgen-1e41a31a8c764e05a4b9b1ef88a3f9e1
This commit is contained in:
Builder.io 2025-08-06 00:32:04 +00:00
parent 80f2285943
commit adefe127ee

View file

@ -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);