diff --git a/app/api/server/v1/roles.js b/app/api/server/v1/roles.js index 67a992427a61..22a0d543ce34 100644 --- a/app/api/server/v1/roles.js +++ b/app/api/server/v1/roles.js @@ -3,6 +3,7 @@ import { Match, check } from 'meteor/check'; import { Roles } from '../../../models'; import { API } from '../api'; +import { getUsersInRole, hasPermission } from '../../../authorization/server'; API.v1.addRoute('roles.list', { authRequired: true }, { get() { @@ -55,3 +56,33 @@ API.v1.addRoute('roles.addUserToRole', { authRequired: true }, { }); }, }); + +API.v1.addRoute('roles.getUsersInRole', { authRequired: true }, { + get() { + const { roomId, role } = this.queryParams; + const { offset, count = 50 } = this.getPaginationItems(); + + const fields = { + name: 1, + username: 1, + emails: 1, + }; + + if (!role) { + throw new Meteor.Error('error-param-not-provided', 'Query param "role" is required'); + } + if (!hasPermission(this.userId, 'access-permissions')) { + throw new Meteor.Error('error-not-allowed', 'Not allowed'); + } + if (roomId && !hasPermission(this.userId, 'view-other-user-channels')) { + throw new Meteor.Error('error-not-allowed', 'Not allowed'); + } + const users = getUsersInRole(role, roomId, { + limit: count, + sort: { username: 1 }, + skip: offset, + fields, + }).fetch(); + return API.v1.success({ users }); + }, +}); diff --git a/app/authorization/client/stylesheets/permissions.css b/app/authorization/client/stylesheets/permissions.css index 9bf8e0f147d1..1561d2ebf536 100644 --- a/app/authorization/client/stylesheets/permissions.css +++ b/app/authorization/client/stylesheets/permissions.css @@ -1,4 +1,9 @@ .permissions-manager { + display: flex; + flex-direction: column; + + height: 100%; + &.page-container { padding-bottom: 0 !important; } diff --git a/app/authorization/client/views/permissionsRole.html b/app/authorization/client/views/permissionsRole.html index 403d69ec50fc..a8a5ac92c312 100644 --- a/app/authorization/client/views/permissionsRole.html +++ b/app/authorization/client/views/permissionsRole.html @@ -1,36 +1,46 @@