Skip to content

Node.js based forum software built for the modern web

fix: #11195, allow users with admin:users privilege to delete users in acp

Barış Soner Uşaklı0bffd3d93cd8
diff --git a/src/api/users.js b/src/api/users.js
index c23f2c04d6..e0382c95cd 100644
--- a/src/api/users.js
+++ b/src/api/users.js
@@ -307,18 +307,17 @@ async function isPrivilegedOrSelfAndPasswordMatch(caller, data) {
async function processDeletion({ uid, method, password, caller }) {
const isTargetAdmin = await user.isAdministrator(uid);
const isSelf = parseInt(uid, 10) === parseInt(caller.uid, 10);
- const isAdmin = await user.isAdministrator(caller.uid);
+ const hasAdminPrivilege = await privileges.admin.can('admin:users', caller.uid);
if (isSelf && meta.config.allowAccountDelete !== 1) {
throw new Error('[[error:account-deletion-disabled]]');
- } else if (!isSelf && !isAdmin) {
+ } else if (!isSelf && !hasAdminPrivilege) {
throw new Error('[[error:no-privileges]]');
} else if (isTargetAdmin) {
throw new Error('[[error:cant-delete-admin]');
}
// Privilege checks -- only deleteAccount is available for non-admins
- const hasAdminPrivilege = await privileges.admin.can('admin:users', caller.uid);
if (!hasAdminPrivilege && ['delete', 'deleteContent'].includes(method)) {
throw new Error('[[error:no-privileges]]');
}