diff --git a/app/auth/signin/page.tsx b/app/auth/signin/page.tsx index c38f5af..f729fd7 100644 --- a/app/auth/signin/page.tsx +++ b/app/auth/signin/page.tsx @@ -17,33 +17,26 @@ export default function SignIn() { useEffect(() => { const urlParams = new URLSearchParams(window.location.search); - const potentialError = urlParams.get("error"); - if (potentialError) { - setError(potentialError); - if (potentialError === "OAuthAccountNotLinked") { - const provider = urlParams.get("provider"); - toast.info(`This account is already linked to ${provider}. Please sign in with that provider.`); - } - } + setError(urlParams.get("error")); }, []); - const handleSignIn = async (provider: string) => { setLoading(true); try { await signIn(provider, { callbackUrl: "/dashboard", }); - } catch (error) { - if (error instanceof Error) { - if (error.message.includes("OAuthAccountNotLinked")) { - toast.info("This account is not linked. Please sign up first or sign in using the originally linked provider."); + } catch (err) { + if (err instanceof Error) { + if (err.message.includes("OAuthAccountNotLinked")) { + const providerName = new URLSearchParams(window.location.search).get("provider"); + toast.info(`This account is already linked to ${providerName}. Please sign in with that provider.`); } else { toast.error("Sign-in failed. Please try again."); - console.error("Sign-in error:", error.message); + console.error("Sign-in error:", err.message); } } else { - console.error("An unexpected error occurred:", error); + console.error("An unexpected error occurred:", err); } } finally { setLoading(false);