From 7c1d1c777b0e0173340a461638dd0fc9e84bf8d4 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 14 Jun 2021 17:14:50 -0400 Subject: [PATCH] refactor(emails): remove email validation on client and server side --- public/src/client/register.js | 40 +++++++------------------------ src/controllers/authentication.js | 15 +++++------- 2 files changed, 14 insertions(+), 41 deletions(-) diff --git a/public/src/client/register.js b/public/src/client/register.js index 92ec1a0e8f..e84de8d1df 100644 --- a/public/src/client/register.js +++ b/public/src/client/register.js @@ -9,7 +9,6 @@ define('forum/register', [ var successIcon = ''; Register.init = function () { - var email = $('#email'); var username = $('#username'); var password = $('#password'); var password_confirm = $('#password-confirm'); @@ -19,17 +18,12 @@ define('forum/register', [ $('#content #noscript').val('false'); - email.on('blur', function () { - if (email.val().length) { - validateEmail(email.val()); - } - }); - - var query = utils.params(); - if (query.email && query.token) { - email.val(decodeURIComponent(query.email)); - $('#token').val(query.token); - } + // TODO: #9607 + // var query = utils.params(); + // if (query.email && query.token) { + // email.val(decodeURIComponent(query.email)); + // $('#token').val(query.token); + // } // Update the "others can mention you via" text username.on('keyup', function () { @@ -58,10 +52,7 @@ define('forum/register', [ validationError = false; validatePassword(password.val(), password_confirm.val()); validatePasswordConfirm(password.val(), password_confirm.val()); - - validateEmail(email.val(), function () { - validateUsername(username.val(), callback); - }); + validateUsername(username.val(), callback); } // Guard against caps lock @@ -119,22 +110,9 @@ define('forum/register', [ }); // Set initial focus - $('#email').focus(); + $('#username').focus(); }; - function validateEmail(email, callback) { - callback = callback || function () {}; - var email_notify = $('#email-notify'); - - if (!utils.isEmailValid(email)) { - showError(email_notify, '[[error:invalid-email]]'); - return callback(); - } - - showSuccess(email_notify, successIcon); - callback(); - } - function validateUsername(username, callback) { callback = callback || function () {}; @@ -175,8 +153,6 @@ define('forum/register', [ showError(password_notify, '[[user:change_password_error]]'); } else if (password === $('#username').val()) { showError(password_notify, '[[user:password_same_as_username]]'); - } else if (password === $('#email').val()) { - showError(password_notify, '[[user:password_same_as_email]]'); } else if (passwordStrength.score < ajaxify.data.minimumPasswordStrength) { showError(password_notify, '[[user:weak_password]]'); } else { diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js index 09fb7d7e78..092efc6e8c 100644 --- a/src/controllers/authentication.js +++ b/src/controllers/authentication.js @@ -53,11 +53,12 @@ async function registerAndLoginUser(req, res, userData) { await authenticationController.doLogin(req, uid); } - // Distinguish registrations through invites from direct ones - if (userData.token) { - await user.joinGroupsFromInvitation(uid, userData.email); - } - await user.deleteInvitationKey(userData.email); + // TODO: #9607 + // // Distinguish registrations through invites from direct ones + // if (userData.token) { + // await user.joinGroupsFromInvitation(uid, userData.email); + // } + // await user.deleteInvitationKey(userData.email); const next = req.session.returnTo || `${nconf.get('relative_path')}/`; const complete = await plugins.hooks.fire('filter:register.complete', { uid: uid, next: next }); req.session.returnTo = complete.next; @@ -80,10 +81,6 @@ authenticationController.register = async function (req, res) { await user.verifyInvitation(userData); } - if (!userData.email) { - throw new Error('[[error:invalid-email]]'); - } - if ( !userData.username || userData.username.length < meta.config.minimumUsernameLength ||