feat: remove administrator property from public routes

v1.18.x
Barış Soner Uşaklı 5 years ago
parent fe352eb1de
commit dfabd0a3fe

@ -533,8 +533,6 @@ UserObjectSlim:
type: string type: string
description: An ISO 8601 formatted date string representing the moment a ban will be lifted, or the words "Not Banned" description: An ISO 8601 formatted date string representing the moment a ban will be lifted, or the words "Not Banned"
example: Not Banned example: Not Banned
administrator:
type: boolean
UserObjectACP: UserObjectACP:
type: object type: object
properties: properties:

@ -3009,8 +3009,6 @@ paths:
type: number type: number
banned_until_readable: banned_until_readable:
type: string type: string
administrator:
type: boolean
userCount: userCount:
type: number type: number
title: title:

@ -175,7 +175,16 @@ async function getUsers(set, section, min, max, req, res) {
} else { } else {
uids = await user.getUidsFromSet(set, start, stop); 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([ const [count, users] = await Promise.all([

@ -66,15 +66,7 @@ User.getUsersFromSet = async function (set, uid, start, stop) {
User.getUsersWithFields = async function (uids, fields, uid) { User.getUsersWithFields = async function (uids, fields, uid) {
let results = await plugins.fireHook('filter:users.addFields', { fields: fields }); let results = await plugins.fireHook('filter:users.addFields', { fields: fields });
results.fields = _.uniq(results.fields); results.fields = _.uniq(results.fields);
const [userData, isAdmin] = await Promise.all([ const userData = await User.getUsersFields(uids, results.fields);
User.getUsersFields(uids, results.fields),
User.isAdministrator(uids),
]);
userData.forEach(function (user, index) {
if (user) {
user.administrator = isAdmin[index];
}
});
results = await plugins.fireHook('filter:userlist.get', { users: userData, uid: uid }); results = await plugins.fireHook('filter:userlist.get', { users: userData, uid: uid });
return results.users; return results.users;
}; };

Loading…
Cancel
Save