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

Unable to fetch user Roles #115

Closed gazzer82 closed 9 years ago

gazzer82 commented 9 years ago

I am trying to get an array of the Roles a user belongs to, and failing miserably.

I have tried the following call, both on the client and the server:

var Roles = Roles.getRolesForUser(userId);

But i always get the following error:

Exception from sub socialPosts id sPK5J8DMx5Ss9kNbt { stack: 'TypeError: Cannot call method \'getRolesForUser\' of undefined\n    at [object Object].Meteor.methods.fetchRoles

I have tried passing in both a user object and users ID and neither seem to work, i have checked with Node Inspector and both the user object and the userID are valid and not null when the Role.getRolesForUser is called.

Any help greatly appreciated.

Gareth

gazzer82 commented 9 years ago

Sorry being an idiot, removing the var from Roles fixed it.

alanning commented 9 years ago

@gazzer82, careful with the use of that variable. If you use Roles as your own variable then you are overwriting the Roles variable which gives access to the roles package. :-)