Closed ghost closed 8 years ago
The way to do that with this package is, for example, this:
Add the allowed users ids to the object
{
_id: "asdfiaj9enrx30m0943",
ownedBy: ["asdfasdf", "asdfasd2"],
...
}
In the action of that role check if the user is in the array
myRole.allow('myAction', function(doc) {
return _.contains(doc.ownedBy, this.userId)
});
Yeah this solves the fact that if i assign role1 to an user, then the role1 is allowed to make some actions on each projectA or projectB according to the .allow method.
However this is not what I intended: the issue is that user1 can have role1 in projectA but role2 in projctB, so I need to assign different roles according to different projects.
In this sense the "group" concept was great. I appreciated your roles implementation but I still don't understand how to create the "group" with your package
You can do it with a action
myRole.allow('hasPermissionInProject', function(doc) {
return _.contains(doc.ownedBy, this.userId)
});
Then check if is in the group
Roles.userHasPermission(this.userId, 'hasPermissionInProject', projectA); // is in project a or no
Hi, i'm using meteor-partitioner in my projects, the package need to use groups to properly working, any clue on how to use it with your roles package?
thanks
Hi!
This way of doing roles is not compatible with groups as other packages do.
But you can get the same functionality. Tell me about what you need to do and I can help you
Hi, thanks, i found another way to implement it using only your (real well written) package
Great!
I've a lot of subprojects in which users may have different authorizations. As far as I've understood the package will allow me to define proj1_role1, proj1_role2, proj1_role3, proj2_role1, proj2_role2, proj2_role3... and so on...
Is there a way to implement "groups" (in the sense of alanning:roles) rather than adding tons of roles to each single user?