redirect for google

This commit is contained in:
Nate Kelley 2025-09-04 13:42:50 -06:00
parent 7ea7cae7bc
commit 6f1a60d4e5
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
2 changed files with 7 additions and 5 deletions

View File

@ -66,12 +66,14 @@ export const LoginForm: React.FC<{
const result = await signInWithGoogle({ data: { redirectTo } });
console.log('result', result);
if (result && 'success' in result && !result.success) {
setErrorMessages([result.error]);
setErrorMessages([result.error || 'An error occurred during sign-in']);
setLoading(null);
return;
}
if (!result?.error) {
navigate({ to: redirectTo || '/' });
if (result && 'success' in result && result.success && result.url) {
// Redirect to OAuth provider's URL
window.location.href = result.url;
}
} catch (error: unknown) {
console.error(error);

View File

@ -62,9 +62,9 @@ export const signInWithGoogle = createServerFn({ method: 'POST' })
return { success: false, error: error.message };
}
console.log('data', data);
console.log('OAuth data:', data);
throw redirect({ href: data.url });
return { success: true, url: data.url };
});
export const signInWithAnonymousUser = createServerFn({ method: 'POST' }).handler(async () => {