diff --git a/apps/web/src/features/auth/components/social-auth.tsx b/apps/web/src/features/auth/components/social-auth.tsx index 1f4b3f52a..f8a71cf42 100644 --- a/apps/web/src/features/auth/components/social-auth.tsx +++ b/apps/web/src/features/auth/components/social-auth.tsx @@ -66,68 +66,20 @@ type SocialAuthButtonsProps = { function SocialAuthButtons({ providers, requestSignUp }: SocialAuthButtonsProps) { const router = useRouter(); - const handleSocialLogin = async (provider: string) => { + const runSignIn = async (fn: () => Promise<{ error: { message?: string } | null }>) => { const toastId = toast.loading(t`Signing in...`); - - const { error } = await authClient.signIn.social(getSocialSignInOptions(provider, requestSignUp)); - + const { error } = await fn(); if (error) { toast.error( error.message || t({ - comment: "Fallback toast when social sign-in fails without a provider error message", + comment: "Fallback toast when sign-in fails without an error message", message: "Failed to sign in. Please try again.", }), { id: toastId }, ); return; } - - toast.dismiss(toastId); - await router.invalidate(); - }; - - const handleOAuthLogin = async () => { - const toastId = toast.loading(t`Signing in...`); - - const { error } = await authClient.signIn.oauth2({ - providerId: "custom", - callbackURL: "/dashboard", - }); - - if (error) { - toast.error( - error.message || - t({ - comment: "Fallback toast when custom OAuth sign-in fails without a provider error message", - message: "Failed to sign in. Please try again.", - }), - { id: toastId }, - ); - return; - } - - toast.dismiss(toastId); - await router.invalidate(); - }; - - const handlePasskeyLogin = async () => { - const toastId = toast.loading(t`Signing in...`); - - const { error } = await authClient.signIn.passkey({ autoFill: false }); - - if (error) { - toast.error( - error.message || - t({ - comment: "Fallback toast when passkey sign-in fails without an error message", - message: "Failed to sign in. Please try again.", - }), - { id: toastId }, - ); - return; - } - toast.dismiss(toastId); await router.invalidate(); }; @@ -136,7 +88,14 @@ function SocialAuthButtons({ providers, requestSignUp }: SocialAuthButtonsProps)