Skip to content

Node.js based forum software built for the modern web

feat: remove administrator property from public routes

Barış Soner Uşaklıdfabd0a3fe08
diff --git a/public/openapi/components/schemas/UserObject.yaml b/public/openapi/components/schemas/UserObject.yaml
index 1509a8ef54..6c6910a239 100644
--- a/public/openapi/components/schemas/UserObject.yaml
+++ b/public/openapi/components/schemas/UserObject.yaml
@@ -533,8 +533,6 @@ UserObjectSlim:
type: string
description: An ISO 8601 formatted date string representing the moment a ban will be lifted, or the words "Not Banned"
example: Not Banned
- administrator:
- type: boolean
UserObjectACP:
type: object
properties:
diff --git a/public/openapi/read.yaml b/public/openapi/read.yaml
index e9e801da7c..4ffac643f1 100644
--- a/public/openapi/read.yaml
+++ b/public/openapi/read.yaml
@@ -3009,8 +3009,6 @@ paths:
type: number
banned_until_readable:
type: string
- administrator:
- type: boolean
userCount:
type: number
title:
diff --git a/src/controllers/admin/users.js b/src/controllers/admin/users.js
index d58bc9077e..106775453f 100644
--- a/src/controllers/admin/users.js
+++ b/src/controllers/admin/users.js
@@ -175,7 +175,16 @@ async function getUsers(set, section, min, max, req, res) {
} else {
uids = await user.getUidsFromSet(set, start, stop);
}
- return await user.getUsersWithFields(uids, userFields, req.uid);
+ const [isAdmin, userData] = await Promise.all([
+ user.isAdministrator(uids),
+ user.getUsersWithFields(uids, userFields, req.uid),
+ ]);
+ userData.forEach((user, index) => {
+ if (user) {
+ user.administrator = isAdmin[index];
+ }
+ });
+ return userData;
}
const [count, users] = await Promise.all([
diff --git a/src/user/index.js b/src/user/index.js
index 7c0d8f8226..81366a9b11 100644
--- a/src/user/index.js
+++ b/src/user/index.js
@@ -66,15 +66,7 @@ User.getUsersFromSet = async function (set, uid, start, stop) {
User.getUsersWithFields = async function (uids, fields, uid) {
let results = await plugins.fireHook('filter:users.addFields', { fields: fields });
results.fields = _.uniq(results.fields);
- const [userData, isAdmin] = await Promise.all([
- User.getUsersFields(uids, results.fields),
- User.isAdministrator(uids),
- ]);
- userData.forEach(function (user, index) {
- if (user) {
- user.administrator = isAdmin[index];
- }
- });
+ const userData = await User.getUsersFields(uids, results.fields);
results = await plugins.fireHook('filter:userlist.get', { users: userData, uid: uid });
return results.users;
};