From 2e8b6b3fef0f16b950ca494da1d6ec67e6e38225 Mon Sep 17 00:00:00 2001 From: SubXi <82209184+SubXi@users.noreply.github.com> Date: Wed, 12 Jul 2023 16:45:39 +0300 Subject: [PATCH] Updated register.js to include password confirmation field Created a new field `PasswordConfirm` and check whether the password matches in both fields, if they do not match a notification will be sent to the user. --- client/pages/register.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/client/pages/register.js b/client/pages/register.js index dad030a..828c601 100644 --- a/client/pages/register.js +++ b/client/pages/register.js @@ -32,6 +32,14 @@ const Register = ({ token: inviteToken, tokenError }) => { e.preventDefault(); setLoading(true); const form = new FormData(e.target); + const password = form.get("password"); + const passwordConfirm = form.get("passwordConfirm"); + + if (password !== passwordConfirm) { + addNotification("error", "Password verification failed! Please ensure both password fields contain the same password."); + setLoading(false); + return; + } try { const res = await fetch(`${SQ_API_URL}/register`, { @@ -43,6 +51,7 @@ const Register = ({ token: inviteToken, tokenError }) => { email: form.get("email"), username: form.get("username"), password: form.get("password"), + password: form.get("passwordConfirm"), invite: inviteToken, }), }); @@ -107,6 +116,13 @@ const Register = ({ token: inviteToken, tokenError }) => { mb={4} required /> + ) : (