From c6f3014c8acea65e7dc29b60f03263e23236173d Mon Sep 17 00:00:00 2001 From: Chisomchima Date: Wed, 11 Dec 2024 14:55:56 +0100 Subject: [PATCH 1/3] feat: disable verify email button if email is not valid --- src/layout/VerifyEmail.component.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/layout/VerifyEmail.component.js b/src/layout/VerifyEmail.component.js index 92e0d833..ce7b1031 100644 --- a/src/layout/VerifyEmail.component.js +++ b/src/layout/VerifyEmail.component.js @@ -9,6 +9,8 @@ const sendEmailVerificationMutation = { type: 'create', } +const emailRegex = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i + export function VerifyEmail({ userEmail }) { const errorAlert = useAlert(({ message }) => message, { critical: true }) const successAlert = useAlert(({ message }) => message, { success: true }) @@ -34,8 +36,10 @@ export function VerifyEmail({ userEmail }) { const emailConfigured = systemInfo?.emailConfigured + const isValidEmail = emailRegex.test(userEmail) + if (!emailConfigured) { - return null // If emailConfigured is false, don't display the button + return null } return ( @@ -43,7 +47,7 @@ export function VerifyEmail({ userEmail }) {