Closed robguinness closed 3 years ago
Well ... there seem to be a lot of people struggling with this.
Please follow the readme and tell me what is unclear: https://github.com/Meteor-Community-Packages/meteor-roles#migration-to-30
Reading through https://github.com/Meteor-Community-Packages/meteor-roles/issues/296 might also help, but then please tell me how the readme can be improved!
tl;dr: You need to publish Role assignments for the feature to work:
Meteor.publish(null, function () {
if (this.userId) {
return Meteor.roleAssignment.find({ 'user._id': this.userId });
} else {
this.ready()
}
})
@vladbalan isn't this quoted from the readme ..?
Closing due to lack of feedback
I am trying to update a project that uses alanning:roles 1.2.19 to version 3.2.2. For some reason after the upgrade, any client-side code that called
Roles.userIsInRole(..)
returns false. Also,Roles.getRolesForUser(..)
returns an empty array.Do I need to do something extra to make this info available to the client? I saw something in the README about publishing the role assignments to the client, but it wasn't clear if this is needed in order to make
Roles.userIsInRole(..)
and other similar APIs function properly on the client.