From 511ab4d03b80db6d6040b4606a9f7d7b97640d01 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 2 Jul 2026 21:21:15 -0400 Subject: [PATCH] fix the login user --- .../[[...sign-in]]/SignInPageClient.tsx | 55 ++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/apps/dashboard/src/app/sign-in/[[...sign-in]]/SignInPageClient.tsx b/apps/dashboard/src/app/sign-in/[[...sign-in]]/SignInPageClient.tsx index 2a94c22..d507228 100644 --- a/apps/dashboard/src/app/sign-in/[[...sign-in]]/SignInPageClient.tsx +++ b/apps/dashboard/src/app/sign-in/[[...sign-in]]/SignInPageClient.tsx @@ -52,6 +52,10 @@ export default function SignInPageClient({ tooManyRequests: "Too many attempts. Please try again later.", emailNotVerified: "Please verify your email first. Check your inbox for the verification link.", + resendVerification: "Resend verification email", + resendingVerification: "Sending…", + verificationResent: + "If that email is registered and not yet verified, a new verification link has been sent.", unexpectedError: "Something went wrong. Please try again.", }, fr: { @@ -76,6 +80,10 @@ export default function SignInPageClient({ tooManyRequests: "Trop de tentatives. Veuillez réessayer plus tard.", emailNotVerified: "Veuillez vérifier votre adresse email. Consultez votre boîte de réception.", + resendVerification: "Renvoyer l'e-mail de vérification", + resendingVerification: "Envoi…", + verificationResent: + "Si cette adresse existe et n'est pas encore vérifiée, un nouveau lien a été envoyé.", unexpectedError: "Une erreur est survenue. Veuillez réessayer.", }, ar: { @@ -100,6 +108,10 @@ export default function SignInPageClient({ tooManyRequests: "محاولات كثيرة جدًا. يرجى المحاولة لاحقًا.", emailNotVerified: "يرجى التحقق من بريدك الإلكتروني أولاً. تحقق من صندوق الوارد.", + resendVerification: "إعادة إرسال رسالة التحقق", + resendingVerification: "جارٍ الإرسال…", + verificationResent: + "إذا كان هذا البريد مسجلاً ولم يتم التحقق منه بعد، فقد تم إرسال رابط جديد.", unexpectedError: "حدث خطأ ما. يرجى المحاولة مرة أخرى.", }, }[language]; @@ -239,6 +251,9 @@ function LocalSignInForm({ emailPlaceholder: string; totpPlaceholder: string; emailNotVerified: string; + resendVerification: string; + resendingVerification: string; + verificationResent: string; unexpectedError: string; }; }) { @@ -250,7 +265,9 @@ function LocalSignInForm({ const [step, setStep] = useState<"credentials" | "totp">("credentials"); const [showPassword, setShowPassword] = useState(false); const [loading, setLoading] = useState(false); + const [resendingVerification, setResendingVerification] = useState(false); const [error, setError] = useState(null); + const [canResendVerification, setCanResendVerification] = useState(false); const requestedPortal = searchParams.get("portal"); const employeeRedirect = searchParams.get("redirect") || "/dashboard"; const preferAdminAuth = requestedPortal === "admin"; @@ -259,6 +276,7 @@ function LocalSignInForm({ e.preventDefault(); setLoading(true); setError(null); + setCanResendVerification(false); try { const tryAdminLogin = async () => { @@ -328,6 +346,7 @@ function LocalSignInForm({ if (empJson?.error === "email_not_verified") { setError(dict.emailNotVerified); + setCanResendVerification(true); return true; } @@ -355,6 +374,30 @@ function LocalSignInForm({ } } + async function handleResendVerification() { + setResendingVerification(true); + setError(null); + + try { + const res = await fetch(`${API_BASE}/auth/employee/resend-verification`, { + method: "POST", + headers: { "Content-Type": "application/json" }, + credentials: "include", + body: JSON.stringify({ email }), + }); + + if (!res.ok) throw new Error(`HTTP ${res.status}`); + + setCanResendVerification(false); + setError(dict.verificationResent); + } catch { + setError(dict.unexpectedError); + setCanResendVerification(true); + } finally { + setResendingVerification(false); + } + } + async function handleTotp(e: React.FormEvent) { e.preventDefault(); setLoading(true); @@ -391,7 +434,17 @@ function LocalSignInForm({ <> {error ? (
- {error} +
{error}
+ {canResendVerification ? ( + + ) : null}
) : null}