More edit changes

This commit is contained in:
Wyatt Johnson
2017-05-12 10:09:25 -06:00
parent f4dfb21e15
commit ed27209de9
10 changed files with 218 additions and 196 deletions
+15
View File
@@ -20,6 +20,21 @@ const User = {
return null;
},
ignoredUsers({id}, args, {user, loaders: {Users}}) {
// Only allow a logged in user that is either the current user or is a staff
// member to access the ignoredUsers of a given user.
if (!user || ((user.id !== id) && !(user.hasRoles('ADMIN') || user.hasRoles('MODERATOR')))) {
return null;
}
// Return nothing if there is nothing to query for.
if (!user.ignoresUsers || user.ignoresUsers.length <= 0) {
return [];
}
return Users.getByQuery({ids: user.ignoresUsers});
},
roles({id, roles}, _, {user}) {
// If the user is not an admin, only return the current user's roles.