Meteor-Community-Packages / meteor-roles

Authorization package for Meteor, compatible with built-in accounts packages
http://meteor-community-packages.github.io/meteor-roles/
MIT License
921 stars 166 forks source link

Excluding GLOBAL_GROUP-only users in getUsersInRole #257

Closed tdukart closed 4 years ago

tdukart commented 6 years ago

I'd like to get a list of users with the 'LOGIN' privilege for a specific group, but exclude the global group.

Here's my use case: Polly is a superadmin for my app, so she has LOGIN privileges in the GLOBAL_GROUP so she can access all of the clients.

Simon is an administrator for the Acme Anvils group. He would need to be able to administer all of Acme's users. However, because Polly is a superadmin, she'd be listed with the other users.

For now, I'll get around this by writing my own query (which I realized I could do while typing this), but it might become difficult to maintain if anything changes within meteor-roles.

I'm happy to write a PR to implement this, but I've never done any Atmosphere development so it'll take some time. Also, I'm not sure the best way to change the API -- new method (getUsersInRoleExcludingGlobal) or a new param to getUsersInRole?

mitar commented 4 years ago

I think you could add another option to getUsersInRole for this.

SimonSimCity commented 4 years ago

In case you still need this feature, you can update to 3.x and use the following code:

Roles.getRolesForUser(user, { onlyScoped: true })

I have no plans on integrating this feature in older versions, but PRs are always welcome.