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
920 stars 164 forks source link

fetching roles across scopes #303

Closed Alex-Mason-1982 closed 4 years ago

Alex-Mason-1982 commented 4 years ago

is there a way to fetch roles across scopes? I've been looking for a while now and cant seem to find the option. I was hoping to be able fetch everyone in a particular role no matter the scope (for things like staff lists).

eg. you have 2 users user1: [{role: 'admin', scope: 'scope1'}] user2: [{role: 'admin', scope: 'scope2'}]

as far as i can tell getUsersInRole(['admin']) will return [] getUsersInRole(['admin'], 'scope1') will return [user1] getUsersInRole(['admin'], 'scope2') will return [user2]

is there an option that will do the following? getUsersInRole(['admin'], SOME_OPTION_HERE) that will return [user1, user2]

SimonSimCity commented 4 years ago

I have to admit, I've been really bad in keeping the documentation updated ...

https://github.com/Meteor-Community-Packages/meteor-roles/blob/ad88577fe37259bf4b1f2a0b2109d3acd21723eb/roles/roles_common.js#L801-L823

This shows that the function getUsersInRole() accepts two parameters:

I guess what you want is getUsersInRole(['admin'], { anyScope: true }) or am I mistaken?

Alex-Mason-1982 commented 4 years ago

Excellent. that is exactly what i was looking for. thank you for your reply.