From 4f4a2295b81341d368fcfe8d80cd84448a75e6be Mon Sep 17 00:00:00 2001 From: Peircharla Bindhu madhavi Date: Tue, 9 Jun 2026 11:24:07 +0530 Subject: [PATCH] feat: add email verification confirmation screen with resend option after registration (issue #243) --- .../src/pages/public/Register.jsx | 53 ++++++++++++++++++- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/RestroHub-FrontEnd/src/pages/public/Register.jsx b/RestroHub-FrontEnd/src/pages/public/Register.jsx index c1d4ed2a..14482777 100644 --- a/RestroHub-FrontEnd/src/pages/public/Register.jsx +++ b/RestroHub-FrontEnd/src/pages/public/Register.jsx @@ -90,6 +90,9 @@ const Register = () => { const [roles, setRoles] = useState([]); const [rolesLoading, setRolesLoading] = useState(false); const [rolesError, setRolesError] = useState(""); + const [registeredEmail, setRegisteredEmail] = useState(""); + const [showVerificationScreen, setShowVerificationScreen] = useState(false); + const [isResending, setIsResending] = useState(false); useEffect(() => { const fetchRoles = async () => { @@ -128,8 +131,9 @@ const Register = () => { const res = await api.post("/public/api/v1/auth/register", registerData); if (res.data.success) { - toast.success("Registration successful! Please login."); - navigate("/login"); + setRegisteredEmail(values.email); + setShowVerificationScreen(true); + toast.success("Registration successful! Please check your email."); } else { toast.error(res.data.message || "Registration failed"); } @@ -141,6 +145,18 @@ const Register = () => { }, }); + const handleResendVerification = async () => { + setIsResending(true); + try { + await api.post("/public/api/v1/auth/resend-verification", { email: registeredEmail }); + toast.success("Verification email resent! Please check your inbox."); + } catch (err) { + toast.error(err.response?.data?.message || "Failed to resend verification email."); + } finally { + setIsResending(false); + } + }; + const inputClass = (field) => `w-full rounded-lg border ${ formik.touched[field] && formik.errors[field] @@ -156,6 +172,39 @@ const Register = () => { formik.setFieldValue("roleIds", nextRoleIds); }; + if (showVerificationScreen) { + return ( +
+
+
+ đź“§ +
+

Check your email

+

+ We sent a verification link to +

+

{registeredEmail}

+

+ Didn't receive the email? Check your spam folder or resend it. +

+ + + Back to Sign In + +
+
+ ); + } + return (