refactor: how admins change emails (#11973)

* refactor: how admins change emails

ability for admins to change emails from acp
ability for admins to change passwords from acp
only users themselves can use /user/<slug>/edit/email
group actions in manage users dropdown
admins can use the same modal from profile page instead of interstitial to update email
add missing checks to addEmail, if email take throw error
add targetUid to email change event

* test: bunch of baloney

* test: remove old test
This commit is contained in:
Barış Soner Uşaklı
2023-08-30 19:29:46 -04:00
committed by GitHub
parent 6ae0d207a7
commit 8db13d8e86
14 changed files with 217 additions and 85 deletions

View File

@@ -90,16 +90,7 @@ editController.username = async function (req, res, next) {
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) {
if (!targetUid || req.uid !== parseInt(targetUid, 10)) {
return next();
}