diff --git a/public/openapi/components/schemas/UserObject.yaml b/public/openapi/components/schemas/UserObject.yaml index 663a159053..d10acf63bc 100644 --- a/public/openapi/components/schemas/UserObject.yaml +++ b/public/openapi/components/schemas/UserObject.yaml @@ -646,6 +646,9 @@ UserObjectACP: type: string description: Email address associated with the user account example: dragonfruit@example.org + emailToConfirm: + type: string + description: Email address user used during signup, this email is not associated with the user until it is confirmed by clicking the link in the confirmation email. postcount: type: number example: 1000 diff --git a/public/src/admin/manage/users.js b/public/src/admin/manage/users.js index 811c6a00d7..1fb8e2701d 100644 --- a/public/src/admin/manage/users.js +++ b/public/src/admin/manage/users.js @@ -242,7 +242,10 @@ define('admin/manage/users', [ } alerts.success('[[admin/manage/users:alerts.validate-email-success]]'); update('.notvalidated', false); - update('.validated', true); + update('.pending', false); + update('.expired', false); + update('.validated', false); + update('.validated-by-admin', true); unselectAll(); }); }); diff --git a/src/controllers/admin/users.js b/src/controllers/admin/users.js index 149d17126f..aab9045eca 100644 --- a/src/controllers/admin/users.js +++ b/src/controllers/admin/users.js @@ -187,11 +187,12 @@ async function loadUserInfo(callerUid, uids) { user.lastonlineISO = utils.toISOString(timestamp); user.ips = ips[index]; user.ip = ips[index] && ips[index][0] ? ips[index][0] : null; - if (confirmObjs[index]) { + user.emailToConfirm = user.email; + if (confirmObjs[index] && confirmObjs[index].email) { const confirmObj = confirmObjs[index]; user['email:expired'] = !confirmObj.expires || Date.now() >= confirmObj.expires; user['email:pending'] = confirmObj.expires && Date.now() < confirmObj.expires; - user.email = confirmObj.email; + user.emailToConfirm = confirmObj.email; } } }); diff --git a/src/user/email.js b/src/user/email.js index 119d5e661b..c5d025cb15 100644 --- a/src/user/email.js +++ b/src/user/email.js @@ -45,16 +45,16 @@ UserEmail.remove = async function (uid, sessionId) { }; UserEmail.getEmailForValidation = async (uid) => { - // gets email from user: email field, - // if it isn't set fallbacks to confirm: email field - let email = await user.getUserField(uid, 'email'); + let email = ''; + // check email from confirmObj + const code = await db.get(`confirm:byUid:${uid}`); + const confirmObj = await db.getObject(`confirm:${code}`); + if (confirmObj && confirmObj.email && parseInt(uid, 10) === parseInt(confirmObj.uid, 10)) { + email = confirmObj.email; + } + if (!email) { - // check email from confirmObj - const code = await db.get(`confirm:byUid:${uid}`); - const confirmObj = await db.getObject(`confirm:${code}`); - if (confirmObj && confirmObj.email && parseInt(uid, 10) === parseInt(confirmObj.uid, 10)) { - email = confirmObj.email; - } + email = await user.getUserField(uid, 'email'); } return email; }; diff --git a/src/views/admin/manage/users.tpl b/src/views/admin/manage/users.tpl index 719ae7de36..b87faf0ea9 100644 --- a/src/views/admin/manage/users.tpl +++ b/src/views/admin/manage/users.tpl @@ -104,21 +104,37 @@ {users.username} - - {{{ if ./email }}} - + +
+ {{{ if (!./email && !./emailToConfirm) }}} + [[admin/manage/users:users.no-email]] + {{{ else }}} + + + {{{ if ./email }}}{./email}{{{ end }}} + - + - + + + {./emailToConfirm} + - + + + {./emailToConfirm} + - {./email} - {{{ else }}} - - [[admin/manage/users:users.no-email]] - {{{ end }}} + + + {./emailToConfirm} + + {{{ end }}} +
{{{ if ./ips.length }}}