Hide suspended user profile (#5452)
This commit is contained in:
parent
a3c7901f87
commit
541f5f1314
6 changed files with 40 additions and 11 deletions
|
|
@ -66,13 +66,18 @@ export const meta = {
|
|||
export default define(meta, async (ps, me) => {
|
||||
let user;
|
||||
|
||||
const isAdminOrModerator = me && (me.isAdmin || me.isModerator);
|
||||
|
||||
if (ps.userIds) {
|
||||
if (ps.userIds.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const users = await Users.find({
|
||||
const users = await Users.find(isAdminOrModerator ? {
|
||||
id: In(ps.userIds)
|
||||
} : {
|
||||
id: In(ps.userIds),
|
||||
isSuspended: false
|
||||
});
|
||||
|
||||
return await Promise.all(users.map(u => Users.pack(u, me, {
|
||||
|
|
@ -93,7 +98,7 @@ export default define(meta, async (ps, me) => {
|
|||
user = await Users.findOne(q);
|
||||
}
|
||||
|
||||
if (user == null) {
|
||||
if (user == null || (!isAdminOrModerator && user.isSuspended)) {
|
||||
throw new ApiError(meta.errors.noSuchUser);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue