MuyBien
MuyBien

Reputation: 163

Meteor role do not exist inside a method but in another

I'm using the alanning role package in a meteor application. I created an admin role and I'm setting this role in another method whithout problem.

But in a method I use : Roles.setUserRoles( userID, 'admin', groupID );. I get a Error: Role 'admin' does not exist. but I know admin exists and I am using the same line in an other methods.

So my question is: What could lead to this error ? (a role do not exist in a method but in another)

Thanks!

Upvotes: 0

Views: 455

Answers (2)

Okei
Okei

Reputation: 127

Do you import the faulty method in the same place as the first one?

Upvotes: 0

NRiebesel
NRiebesel

Reputation: 317

Why don't you use 'addUsersToRoles' or maybe something's wrong with the groupID. It works well for me with that code:

Roles.addUsersToRoles(userId, 'admin', Roles.GLOBAL_GROUP);

or to remove:

Roles.removeUsersFromRoles(userId, 'admin', Roles.GLOBAL_GROUP);

And in a Markup for e.g.:

{{#if isInRole 'admin' }}
You're Admin.
{{/if}}

Upvotes: 0

Related Questions