Closed lookingcloudy closed 9 years ago
Hi @lookingcloudy, because a group was specified when you added the role/permission, you must also use the group when checking to see if the user has that permission:
{{#if ifInRole 'admin' 'default-group'}}
<a class="waves-effect waves-light btn">Stuff</a>
{{else}}
<p>Login required</p>
{{/if}}
Roles.userIsInRole(user, 'admin', 'default-group')
If you want the permission to apply irrespective of groups, then use Roles.GLOBAL_GROUP as the group:
Roles.addUsersToRoles(id, user.roles, Roles.GLOBAL_GROUP)
I'll update the readme to hopefully be more clear on that.
Also, just fyi, in mongo you can avoid $elemMatch by changing your key like so:
Meteor.users.findOne({'emails.address':'brad@blah.org'})
Thanks!
On Mon, Aug 31, 2015 at 2:01 PM, Adrian Lanning notifications@github.com wrote:
Hi @lookingcloudy https://github.com/lookingcloudy, because a group was specified when you added the role/permission, you must also use the group when checking to see if the user has that permission:
{{#if ifInRole 'admin' 'default-group'}} Stuff {{else}}
Login required
{{/if}}
Roles.userIsInRole(user, 'admin', 'default-group')
If you want the permission to apply irrespective of groups, then use Roles.GLOBAL_GROUP as the group:
Roles.addUsersToRoles(id, user.roles, Roles.GLOBAL_GROUP)
I'll update the readme to hopefully be more clear on that.
Also, just fyi, in mongo you can avoid $elemMatch by changing your key like so: Meteor.users.findOne({'emails.address':'brad@blah.org'})
— Reply to this email directly or view it on GitHub https://github.com/alanning/meteor-roles/issues/122#issuecomment-136447020 .
I created users server side as per your docs:
This does not work:
Nor does this work: