mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
feat(emails): restore ability for admins to edit a user's email address [breaking]
The edited user's email will be automatically confirmed
This commit is contained in:
@@ -77,10 +77,24 @@ editController.username = async function (req, res, next) {
|
||||
await renderRoute('username', req, res, next);
|
||||
};
|
||||
|
||||
editController.email = async function (req, res) {
|
||||
editController.email = async function (req, res, next) {
|
||||
const targetUid = await user.getUidByUserslug(req.params.userslug);
|
||||
if (!targetUid) {
|
||||
return next();
|
||||
}
|
||||
|
||||
const [isAdminOrGlobalMod, canEdit] = await Promise.all([
|
||||
user.isAdminOrGlobalMod(req.uid),
|
||||
privileges.users.canEdit(req.uid, targetUid),
|
||||
]);
|
||||
|
||||
if (!isAdminOrGlobalMod && !canEdit) {
|
||||
return next();
|
||||
}
|
||||
|
||||
req.session.registration = req.session.registration || {};
|
||||
req.session.registration.updateEmail = true;
|
||||
req.session.registration.uid = req.uid;
|
||||
req.session.registration.uid = targetUid;
|
||||
helpers.redirect(res, '/register/complete');
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user