From 7d0ebd3c54d3b352e5d9a61bb7aaf06481d9644a Mon Sep 17 00:00:00 2001 From: Dhruwang Jariwala <67850763+Dhruwang@users.noreply.github.com> Date: Mon, 30 Oct 2023 16:04:29 +0530 Subject: [PATCH] fix: Error message on Login not shown (#1508) --- .../app/(auth)/auth/login/components/SigninForm.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/web/app/(auth)/auth/login/components/SigninForm.tsx b/apps/web/app/(auth)/auth/login/components/SigninForm.tsx index 3ae39372e6..5872e60324 100644 --- a/apps/web/app/(auth)/auth/login/components/SigninForm.tsx +++ b/apps/web/app/(auth)/auth/login/components/SigninForm.tsx @@ -6,7 +6,7 @@ import { XCircleIcon } from "@heroicons/react/24/solid"; import { signIn } from "next-auth/react"; import Link from "next/dist/client/link"; import { useRouter, useSearchParams } from "next/navigation"; -import { useMemo, useRef, useState } from "react"; +import { useMemo, useRef, useState, useEffect } from "react"; import { Controller, SubmitHandler, useForm, FormProvider } from "react-hook-form"; import { cn } from "@formbricks/lib/cn"; @@ -88,10 +88,16 @@ export const SigninForm = ({ const [totpBackup, setTotpBackup] = useState(false); const [signInError, setSignInError] = useState(""); const formRef = useRef(null); - + const error = searchParams?.get("error"); const callbackUrl = searchParams?.get("callbackUrl"); const inviteToken = callbackUrl ? new URL(callbackUrl).searchParams.get("token") : null; + useEffect(() => { + if (error) { + setSignInError(error); + } + }, []); + const formLabel = useMemo(() => { if (totpBackup) { return "Enter your backup code";