Skip to content
Snippets Groups Projects
Commit 273d9b80 authored by Diego Sampaio's avatar Diego Sampaio
Browse files

users in role pagination support

parent 300feb7a
No related branches found
No related tags found
No related merge requests found
RocketChat.authz.getUsersInRole = (roleName, scope) -> RocketChat.authz.getUsersInRole = (roleName, scope, options) ->
# alanning:roles doc says this is an expensive operation # alanning:roles doc says this is an expensive operation
unless _.isString(scope) unless _.isString(scope)
scope = Roles.GLOBAL_GROUP scope = Roles.GLOBAL_GROUP
return Roles.getUsersInRole(roleName, scope) return Roles.getUsersInRole(roleName, scope, options)
\ No newline at end of file
Meteor.publish 'usersInRole', (roleName) -> Meteor.publish 'usersInRole', (roleName, page = 1) ->
unless @userId unless @userId
return @ready() return @ready()
if not RocketChat.authz.hasPermission @userId, 'access-rocket-permissions' if not RocketChat.authz.hasPermission @userId, 'access-rocket-permissions'
throw new Meteor.Error "not-authorized" throw new Meteor.Error "not-authorized"
return RocketChat.authz.getUsersInRole roleName itemsPerPage = 20
pagination =
sort:
name: 1
limit: itemsPerPage
offset: itemsPerPage * (page - 1)
return RocketChat.authz.getUsersInRole roleName, null, pagination
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment