Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disable verify email button #1454

Merged
merged 4 commits into from
Dec 13, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/layout/VerifyEmail.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Chisomchima marked this conversation as resolved.
Show resolved Hide resolved

export function VerifyEmail({ userEmail }) {
const errorAlert = useAlert(({ message }) => message, { critical: true })
const successAlert = useAlert(({ message }) => message, { success: true })
Expand All @@ -34,16 +36,18 @@ 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 (
<div style={{ display: 'flex', alignItems: 'center', gap: '10px' }}>
<Button
secondary
onClick={mutateEmailVerification}
disabled={mutationLoading || !userEmail}
disabled={mutationLoading || !isValidEmail || !userEmail}
loading={mutationLoading}
>
{i18n.t('Verify Email')}
Expand Down
Loading