allow moderators to view role

This commit is contained in:
Wyatt Johnson
2018-01-11 14:00:26 -07:00
parent 139d319965
commit 4d65052eef
3 changed files with 4 additions and 2 deletions
+2 -2
View File
@@ -4,7 +4,7 @@ const {
SEARCH_ACTIONS,
SEARCH_OTHER_USERS,
SEARCH_OTHERS_COMMENTS,
UPDATE_USER_ROLES,
VIEW_USER_ROLE,
LIST_OWN_TOKENS,
VIEW_USER_STATUS,
} = require('../../perms/constants');
@@ -68,7 +68,7 @@ const User = {
role({id, role}, _, {user}) {
// If the user is not an admin, only return the current user's roles.
if (user && (user.can(UPDATE_USER_ROLES) || user.id === id)) {
if (user && (user.can(VIEW_USER_ROLE) || user.id === id)) {
return role;
}
+1
View File
@@ -8,4 +8,5 @@ module.exports = {
VIEW_USER_STATUS: 'VIEW_USER_STATUS',
VIEW_PROTECTED_SETTINGS: 'VIEW_PROTECTED_SETTINGS',
LIST_OWN_TOKENS: 'LIST_OWN_TOKENS',
VIEW_USER_ROLE: 'VIEW_USER_ROLE',
};
+1
View File
@@ -12,6 +12,7 @@ module.exports = (user, perm) => {
case types.SEARCH_COMMENT_STATUS_HISTORY:
case types.VIEW_USER_STATUS:
case types.VIEW_PROTECTED_SETTINGS:
case types.VIEW_USER_ROLE:
return check(user, ['ADMIN', 'MODERATOR']);
case types.LIST_OWN_TOKENS:
return check(user, ['ADMIN']);