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 168 forks source link

MongoError: cannot use the part (roles of roles.__global_roles__) to traverse the element #80

Closed jimmiebtlr closed 9 years ago

jimmiebtlr commented 9 years ago

The user in question has roles that are not part of a group. I am trying to add a role which is part of

Roles.GLOBAL_GROUP

and I get the following error

MongoError: cannot use the part (roles of roles.__global_roles__) to traverse the element 

Any insight into it's meaning would be great, thanks. Not really sure where to start on this.

alanning commented 9 years ago

I would guess that it has to do with the structure of the roles field on the user object.

The choice to use groups should be a global one; either all users should use groups or none of your users should use them. To convert from no-groups to groups, you would manually change the structure to match what the roles package expects as shown here: https://github.com/alanning/meteor-roles#changes-to-default-meteor-behavior

Here's a small script that I used when we did the conversion for our startup: https://gist.github.com/alanning/0686f29c71b8cab54cc7

Any issues, let me know.

jimmiebtlr commented 9 years ago

That was indeed the issue, thanks a ton.