From 7624af5769134524dee6fdb53db8107477ea4687 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 12 Nov 2021 14:58:02 -0500 Subject: [PATCH] feat: add feature flag to disable verification emails, closes #9996 --- install/data/defaults.json | 1 + .../language/en-GB/admin/settings/email.json | 3 ++- src/user/email.js | 7 +++++++ src/views/admin/settings/email.tpl | 21 ++++++++++++------- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/install/data/defaults.json b/install/data/defaults.json index 52b7683954..cd01e7644a 100644 --- a/install/data/defaults.json +++ b/install/data/defaults.json @@ -138,6 +138,7 @@ "disableEmailSubscriptions": 0, "emailConfirmInterval": 10, "removeEmailNotificationImages": 0, + "sendValidationEmail": 1, "includeUnverifiedEmails": 0, "emailPrompt": 1, "inviteExpiration": 7, diff --git a/public/language/en-GB/admin/settings/email.json b/public/language/en-GB/admin/settings/email.json index 65f579d28c..17c60daf69 100644 --- a/public/language/en-GB/admin/settings/email.json +++ b/public/language/en-GB/admin/settings/email.json @@ -38,7 +38,8 @@ "subscriptions.hour-help": "Please enter a number representing the hour to send scheduled email digests (e.g. 0 for midnight, 17 for 5:00pm). Keep in mind that this is the hour according to the server itself, and may not exactly match your system clock.
The approximate server time is:
The next daily digest is scheduled to be sent ", "notifications.remove-images": "Remove images from email notifications", "require-email-address": "Require new users to specify an email address", - "require-email-address-warning": "By default, users can opt-out of entering an email address. Enabling this option means they have to enter an email address in order to proceed with registration. It does not ensure user will enter a real email address, nor even an address they own.", + "require-email-address-warning": "By default, users can opt-out of entering an email address by leaving the field blank. Enabling this option means they have to enter an email address in order to proceed with registration. It does not ensure user will enter a real email address, nor even an address they own.", + "send-validation-email": "Send validation emails when an email is added or changed", "include-unverified-emails": "Send emails to recipients who have not explicitly confirmed their emails", "include-unverified-warning": "By default, users with emails associated with their account have already been verified, but there are situations where this is not the case (e.g. SSO logins, grandfathered users, etc). Enable this setting at your own risk – sending emails to unverified addresses may be a violation of regional anti-spam laws.", "prompt": "Prompt users to enter or confirm their emails", diff --git a/src/user/email.js b/src/user/email.js index d6d2d32b4d..a97aa1f38f 100644 --- a/src/user/email.js +++ b/src/user/email.js @@ -2,6 +2,7 @@ 'use strict'; const nconf = require('nconf'); +const winston = require('winston'); const user = require('./index'); const utils = require('../utils'); @@ -69,6 +70,11 @@ UserEmail.sendValidationEmail = async function (uid, options) { * - force, sends email even if it is too soon to send another */ + if (meta.config.sendValidationEmail !== 1) { + winston.verbose(`[user/email] Validation email for uid ${uid} not sent due to config settings`); + return; + } + options = options || {}; // Fallback behaviour (email passed in as second argument) @@ -110,6 +116,7 @@ UserEmail.sendValidationEmail = async function (uid, options) { await db.expireAt(`confirm:${confirm_code}`, Math.floor((Date.now() / 1000) + (60 * 60 * 24))); const username = await user.getUserField(uid, 'username'); + winston.verbose(`[user/email] Validation email for uid ${uid} sent to ${options.email}`); events.log({ type: 'email-confirmation-sent', uid, diff --git a/src/views/admin/settings/email.tpl b/src/views/admin/settings/email.tpl index 7f90431b96..e5b3fab134 100644 --- a/src/views/admin/settings/email.tpl +++ b/src/views/admin/settings/email.tpl @@ -20,13 +20,6 @@
-
- -
-

[[admin/settings/email:require-email-address-warning]]

+
+ +
+

[[admin/settings/email:prompt-help]]

+ +
+ +