refactor(emails): remove email validation on client and server side

v1.18.x
Julian Lam 4 years ago
parent 12b2a979a0
commit 7c1d1c777b

@ -9,7 +9,6 @@ define('forum/register', [
var successIcon = ''; var successIcon = '';
Register.init = function () { Register.init = function () {
var email = $('#email');
var username = $('#username'); var username = $('#username');
var password = $('#password'); var password = $('#password');
var password_confirm = $('#password-confirm'); var password_confirm = $('#password-confirm');
@ -19,17 +18,12 @@ define('forum/register', [
$('#content #noscript').val('false'); $('#content #noscript').val('false');
email.on('blur', function () { // TODO: #9607
if (email.val().length) { // var query = utils.params();
validateEmail(email.val()); // if (query.email && query.token) {
} // email.val(decodeURIComponent(query.email));
}); // $('#token').val(query.token);
// }
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 // Update the "others can mention you via" text
username.on('keyup', function () { username.on('keyup', function () {
@ -58,10 +52,7 @@ define('forum/register', [
validationError = false; validationError = false;
validatePassword(password.val(), password_confirm.val()); validatePassword(password.val(), password_confirm.val());
validatePasswordConfirm(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 // Guard against caps lock
@ -119,22 +110,9 @@ define('forum/register', [
}); });
// Set initial focus // 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) { function validateUsername(username, callback) {
callback = callback || function () {}; callback = callback || function () {};
@ -175,8 +153,6 @@ define('forum/register', [
showError(password_notify, '[[user:change_password_error]]'); showError(password_notify, '[[user:change_password_error]]');
} else if (password === $('#username').val()) { } else if (password === $('#username').val()) {
showError(password_notify, '[[user:password_same_as_username]]'); 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) { } else if (passwordStrength.score < ajaxify.data.minimumPasswordStrength) {
showError(password_notify, '[[user:weak_password]]'); showError(password_notify, '[[user:weak_password]]');
} else { } else {

@ -53,11 +53,12 @@ async function registerAndLoginUser(req, res, userData) {
await authenticationController.doLogin(req, uid); await authenticationController.doLogin(req, uid);
} }
// Distinguish registrations through invites from direct ones // TODO: #9607
if (userData.token) { // // Distinguish registrations through invites from direct ones
await user.joinGroupsFromInvitation(uid, userData.email); // if (userData.token) {
} // await user.joinGroupsFromInvitation(uid, userData.email);
await user.deleteInvitationKey(userData.email); // }
// await user.deleteInvitationKey(userData.email);
const next = req.session.returnTo || `${nconf.get('relative_path')}/`; const next = req.session.returnTo || `${nconf.get('relative_path')}/`;
const complete = await plugins.hooks.fire('filter:register.complete', { uid: uid, next: next }); const complete = await plugins.hooks.fire('filter:register.complete', { uid: uid, next: next });
req.session.returnTo = complete.next; req.session.returnTo = complete.next;
@ -80,10 +81,6 @@ authenticationController.register = async function (req, res) {
await user.verifyInvitation(userData); await user.verifyInvitation(userData);
} }
if (!userData.email) {
throw new Error('[[error:invalid-email]]');
}
if ( if (
!userData.username || !userData.username ||
userData.username.length < meta.config.minimumUsernameLength || userData.username.length < meta.config.minimumUsernameLength ||

Loading…
Cancel
Save