Allow clearing user account email.

Ylian Saint-Hilaire committed Oct 16, 2020 at 13:17 UTC 6d1f757bfc59132b5e5352ebc51e63ac433ad69d
2 files changed +7 -5
meshuser.js
+2 -2
@@ -1997,8 +1997,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
1997
1998 // Validate and change email
1999 if (edituserdomain.usernameisemail !== true) {
2000 - if (common.validateString(command.email, 1, 1024) && (chguser.email != command.email)) {
2001 - if (command.email == '') { delete chguser.email; } else { chguser.email = command.email.toLowerCase(); }
2000 + if (common.validateString(command.email, 0, 1024) && (chguser.email != command.email)) {
2001 + if (command.email == '') { command.emailVerified = false; delete chguser.email; } else { chguser.email = command.email.toLowerCase(); }
2002 change = 1;
2003 }
2004 }
views/default.handlebars
+5 -3
@@ -12026,11 +12026,13 @@
12026 if (user.name.toLowerCase() != user._id.split('/')[2]) { x += addDeviceAttribute("User Identifier", EscapeHtml(user._id.split('/')[2])); }
12027 }
12028
12029 + var emailLink = '';
12030 + if (user.email) { emailLink = ' <a href="mailto:' + EscapeHtml(user.email) + '" \'><img class=hoverButton src="images/link1.png" /></a>'; }
12031 if (((user.siteadmin != 0xFFFFFFFF) || (userinfo.siteadmin == 0xFFFFFFFF))) { // If we are not site admin, we can't change a admin email or real name
12030 - x += addDeviceAttribute("Email", everify + email + ' <a href="mailto:' + EscapeHtml(user.email) + '" \'><img class=hoverButton src="images/link1.png" /></a>' + ' <img class=hoverButton style=cursor:pointer src="images/link5.png" onclick=p30showUserEmailChangeDialog(event,"' + userid + '") />');
12032 + x += addDeviceAttribute("Email", everify + email + emailLink + ' <img class=hoverButton style=cursor:pointer src="images/link5.png" onclick=p30showUserEmailChangeDialog(event,"' + userid + '") />');
12033 x += addDeviceAttribute("Real Name", realname + ' <img class=hoverButton style=cursor:pointer src="images/link5.png" onclick=p30showUserRealNameChangeDialog(event,"' + userid + '") />');
12034 } else {
12033 - x += addDeviceAttribute("Email", everify + email + ' <a href="mailto:' + EscapeHtml(user.email) + '" \'><img class=hoverButton src="images/link1.png" /></a>');
12035 + x += addDeviceAttribute("Email", everify + email + emailLink);
12036 x += addDeviceAttribute("Real Name", realname);
12037 }
12038
@@ -12185,7 +12187,7 @@
12187 // Perform validation on the user's email change dialog box
12188 function p30validateEmail() {
12189 var v = Q('dp30email').value, x = v.split('@');
12188 - x = (x.length == 2) && (x[0].length > 0) && (x[1].split('.').length > 1) && (x[1].length > 2) && (v.length < 1024) && ((v != userinfo.email) || ((serverinfo.emailcheck == true) && (Q('dp30verified').value != (userinfo.emailVerified?1:0))));
12190 + x = (v.length == 0) || ((x.length == 2) && (x[0].length > 0) && (x[1].split('.').length > 1) && (x[1].length > 2) && (v.length < 1024) && ((v != userinfo.email) || ((serverinfo.emailcheck == true) && (Q('dp30verified').value != (userinfo.emailVerified?1:0)))));
12191 QE('idx_dlgOkButton', x);
12192 }
12193