mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 16:35:47 +01:00
fix: replace logic in isPrivilegedOrSelfAndPasswordMatch to use privileges.users.canEdit
This commit is contained in:
@@ -227,14 +227,9 @@ usersAPI.unban = async function (caller, data) {
|
||||
async function isPrivilegedOrSelfAndPasswordMatch(caller, data) {
|
||||
const { uid } = caller;
|
||||
const isSelf = parseInt(uid, 10) === parseInt(data.uid, 10);
|
||||
const canEdit = await privileges.users.canEdit(uid, data.uid);
|
||||
|
||||
const [isAdmin, isTargetAdmin, isGlobalMod] = await Promise.all([
|
||||
user.isAdministrator(uid),
|
||||
user.isAdministrator(data.uid),
|
||||
user.isGlobalModerator(uid),
|
||||
]);
|
||||
|
||||
if ((isTargetAdmin && !isAdmin) || (!isSelf && !(isAdmin || isGlobalMod))) {
|
||||
if (!canEdit) {
|
||||
throw new Error('[[error:no-privileges]]');
|
||||
}
|
||||
const [hasPassword, passwordMatch] = await Promise.all([
|
||||
|
||||
Reference in New Issue
Block a user