fix(email): send verification email for email updates regardless of IS_EMAIL_VERIFICATION_REQUIRED

https://sonarly.com/issue/32182?type=bug

The email change flow reuses the sign-up email verification method which has a guard that silently skips sending when `IS_EMAIL_VERIFICATION_REQUIRED` is `false` (the default). The mutation returns success to the frontend, which displays "Check your inbox" — but no email is ever sent, permanently blocking email changes on self-hosted instances.

Fix: Modified `sendVerificationEmail` in `email-verification.service.ts` to bypass the `IS_EMAIL_VERIFICATION_REQUIRED` guard when the verification trigger is `EMAIL_UPDATE`.

**Before:** The method checked `IS_EMAIL_VERIFICATION_REQUIRED` and returned `{ success: false }` unconditionally when it was `false` (the default). This meant email-update verification emails were silently suppressed.

**After:** The early return only applies when `IS_EMAIL_VERIFICATION_REQUIRED` is `false` AND the trigger is NOT `EMAIL_UPDATE`. For email updates, the verification email is always sent regardless of the config flag, because verifying ownership of the new email address is mandatory to complete the change (unlike sign-up verification, which is an optional security setting).

This is a one-line logical change — adding `&& verificationTrigger !== EmailVerificationTrigger.EMAIL_UPDATE` to the existing guard condition. All sign-up paths (which use the default `SIGN_UP` trigger) continue to respect the `IS_EMAIL_VERIFICATION_REQUIRED` config flag as before.
This commit is contained in:
Sonarly Claude Code
2026-04-28 18:09:54 +00:00
parent d2dda67596
commit 6f21781e6b
@@ -59,7 +59,14 @@ export class EmailVerificationService {
verifyEmailRedirectPath?: string;
verificationTrigger?: EmailVerificationTrigger;
}) {
if (!this.twentyConfigService.get('IS_EMAIL_VERIFICATION_REQUIRED')) {
const isEmailVerificationRequired = this.twentyConfigService.get(
'IS_EMAIL_VERIFICATION_REQUIRED',
);
if (
!isEmailVerificationRequired &&
verificationTrigger !== EmailVerificationTrigger.EMAIL_UPDATE
) {
return { success: false };
}