Skip to content

Commit

Permalink
feat: remove administrator property from public routes
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed Aug 5, 2020
1 parent fe352eb commit dfabd0a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
2 changes: 0 additions & 2 deletions public/openapi/components/schemas/UserObject.yaml
Expand Up @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions public/openapi/read.yaml
Expand Up @@ -3009,8 +3009,6 @@ paths:
type: number
banned_until_readable:
type: string
administrator:
type: boolean
userCount:
type: number
title:
Expand Down
11 changes: 10 additions & 1 deletion src/controllers/admin/users.js
Expand Up @@ -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([
Expand Down
10 changes: 1 addition & 9 deletions src/user/index.js
Expand Up @@ -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;
};
Expand Down

0 comments on commit dfabd0a

Please sign in to comment.