Node.js based forum software built for the modern web
feat: add ACP option to require email address on new registration
Julian Lam006fc700ddc6
diff --git a/public/language/en-GB/admin/settings/email.json b/public/language/en-GB/admin/settings/email.jsonindex 9bdbde26a6..af4e100eb6 100644--- a/public/language/en-GB/admin/settings/email.json+++ b/public/language/en-GB/admin/settings/email.json@@ -37,6 +37,8 @@"subscriptions.hour": "Digest Hour","subscriptions.hour-help": "Please enter a number representing the hour to send scheduled email digests (e.g. <code>0</code> for midnight, <code>17</code> for 5:00pm). Keep in mind that this is the hour according to the server itself, and may not exactly match your system clock.<br /> The approximate server time is: <span id=\"serverTime\"></span><br /> The next daily digest is scheduled to be sent <span id=\"nextDigestTime\"></span>","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. <strong>It does not ensure user will enter a real email address, nor even an address they own.</strong>","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). <strong>Enable this setting at your own risk</strong> – sending emails to unverified addresses may be a violation of regional anti-spam laws."}\ No newline at end of filediff --git a/src/user/interstitials.js b/src/user/interstitials.jsindex 5467711503..3a98b12373 100644--- a/src/user/interstitials.js+++ b/src/user/interstitials.js@@ -57,9 +57,15 @@ Interstitials.email = async (data) => {// User attempting to edit another user's email -- not allowedthrow new Error('[[error:no-privileges]]');}- } else if (current) {- // User explicitly clearing their email- await user.email.remove(userData.uid, data.req.session.id);+ } else {+ if (meta.config.requireEmailAddress) {+ throw new Error('[[error:invalid-email]]');+ }++ if (current) {+ // User explicitly clearing their email+ await user.email.remove(userData.uid, data.req.session.id);+ }}} else {// New registrants have the confirm email sent from user.create()diff --git a/src/views/admin/settings/email.tpl b/src/views/admin/settings/email.tplindex 76286d117e..9d33950d7a 100644--- a/src/views/admin/settings/email.tpl+++ b/src/views/admin/settings/email.tpl@@ -27,6 +27,14 @@</label></div>+ <div class="checkbox">+ <label for="requireEmailAddress" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">+ <input class="mdl-switch__input" type="checkbox" id="requireEmailAddress" data-field="requireEmailAddress" name="requireEmailAddress" />+ <span class="mdl-switch__label">[[admin/settings/email:require-email-address]]</span>+ </label>+ </div>+ <p class="help-block">[[admin/settings/email:require-email-address-warning]]</p>+<div class="checkbox"><label for="includeUnverifiedEmails" class="mdl-switch mdl-js-switch mdl-js-ripple-effect"><input class="mdl-switch__input" type="checkbox" id="includeUnverifiedEmails" data-field="includeUnverifiedEmails" name="includeUnverifiedEmails" />