我已经在我的流星反应项目中添加了allaning:roles,但是Roles.userIsInRole(Meteor.userId((, ["ADMIN"](总是返回 false。 我在我的蒙戈中的角色如下,
{ "_id" : "9B3D757wQA9Mz4RGt", "name" : "BUYER" }
{ "_id" : "PDCJH8D6JDo9fttFj", "name" : "ADMINKAMB" }
{ "_id" : "XFGsrfB3Xsm6F8LbQ", "name" : "SELLER" }
{ "_id" : "hDLSvdo6wMnF47BBz", "name" : "ADMIN" }
{ "_id" : "ADMINKAMB", "children" : [ ] }
如果从包中删除自动发布,请尝试添加此代码
For my case, I create a file /imports/startup/server/publications/index.js
Meteor.publish(null, function() {
if (this.userId) {
return Meteor.roleAssignment.find({ 'user._id': this.userId });
}
return this.ready();
});
然后在服务器/主服务器中.js
import '/imports/startup/server/publications'