Allow clearing user account email.

This commit is contained in:
Ylian Saint-Hilaire 2020-10-16 13:17:39 -07:00
parent 902af05ec5
commit 29bbe882e5
2 changed files with 7 additions and 5 deletions

View File

@ -1997,8 +1997,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Validate and change email // Validate and change email
if (edituserdomain.usernameisemail !== true) { if (edituserdomain.usernameisemail !== true) {
if (common.validateString(command.email, 1, 1024) && (chguser.email != command.email)) { if (common.validateString(command.email, 0, 1024) && (chguser.email != command.email)) {
if (command.email == '') { delete chguser.email; } else { chguser.email = command.email.toLowerCase(); } if (command.email == '') { command.emailVerified = false; delete chguser.email; } else { chguser.email = command.email.toLowerCase(); }
change = 1; change = 1;
} }
} }

View File

@ -12026,11 +12026,13 @@
if (user.name.toLowerCase() != user._id.split('/')[2]) { x += addDeviceAttribute("User Identifier", EscapeHtml(user._id.split('/')[2])); } if (user.name.toLowerCase() != user._id.split('/')[2]) { x += addDeviceAttribute("User Identifier", EscapeHtml(user._id.split('/')[2])); }
} }
var emailLink = '';
if (user.email) { emailLink = ' <a href="mailto:' + EscapeHtml(user.email) + '" \'><img class=hoverButton src="images/link1.png" /></a>'; }
if (((user.siteadmin != 0xFFFFFFFF) || (userinfo.siteadmin == 0xFFFFFFFF))) { // If we are not site admin, we can't change a admin email or real name if (((user.siteadmin != 0xFFFFFFFF) || (userinfo.siteadmin == 0xFFFFFFFF))) { // If we are not site admin, we can't change a admin email or real name
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 + '") />'); x += addDeviceAttribute("Email", everify + email + emailLink + ' <img class=hoverButton style=cursor:pointer src="images/link5.png" onclick=p30showUserEmailChangeDialog(event,"' + userid + '") />');
x += addDeviceAttribute("Real Name", realname + ' <img class=hoverButton style=cursor:pointer src="images/link5.png" onclick=p30showUserRealNameChangeDialog(event,"' + userid + '") />'); x += addDeviceAttribute("Real Name", realname + ' <img class=hoverButton style=cursor:pointer src="images/link5.png" onclick=p30showUserRealNameChangeDialog(event,"' + userid + '") />');
} else { } else {
x += addDeviceAttribute("Email", everify + email + ' <a href="mailto:' + EscapeHtml(user.email) + '" \'><img class=hoverButton src="images/link1.png" /></a>'); x += addDeviceAttribute("Email", everify + email + emailLink);
x += addDeviceAttribute("Real Name", realname); x += addDeviceAttribute("Real Name", realname);
} }
@ -12185,7 +12187,7 @@
// Perform validation on the user's email change dialog box // Perform validation on the user's email change dialog box
function p30validateEmail() { function p30validateEmail() {
var v = Q('dp30email').value, x = v.split('@'); var v = Q('dp30email').value, x = v.split('@');
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)))); 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)))));
QE('idx_dlgOkButton', x); QE('idx_dlgOkButton', x);
} }