检查用户是否在meteor中扮演角色的正确方法?
我正在构建一个CMS,根据用户检查用户是否在meteor中扮演角色的正确方法?,meteor,angular-meteor,Meteor,Angular Meteor,我正在构建一个CMS,根据用户角色的不同,他们将能够编辑/更新/删除/创建不同的区域,但通过他们的角色进行过滤,例如,一个具有角色的用户:“基本角色”不能删除具有角色的用户:“超级用户”可以删除的内容 我目前的情况是: Collection.allow({ insert: function(userId, collection) { return Meteor.users.findOne({_id: userId, profile: {role: 'admin'}}); },
角色
的不同,他们将能够编辑/更新/删除/创建不同的区域,但通过他们的角色
进行过滤,例如,一个具有角色的用户:“基本角色”
不能删除具有角色的用户:“超级用户”
可以删除的内容
我目前的情况是:
Collection.allow({
insert: function(userId, collection) {
return Meteor.users.findOne({_id: userId, profile: {role: 'admin'}});
},
update: function(userId, collection, fields, modifier) {
return Meteor.users.findOne({_id: userId, profile: {role: 'admin'}});
},
remove: function(userId, collection) {
return Meteor.users.findOne({_id: userId, profile: {role: 'admin'}});
}
});
问题
这是验证用户角色的正确方法吗?有更好的方法吗?这方面的最佳实践是什么
谢谢 你应该看看包装。它被广泛使用,甚至在Meteor文档中被提及。除了角色之外,它还支持组。您应该看看这个包。它被广泛使用,甚至在Meteor文档中被提及。除了角色,它还支持组。这是Meteor的规范角色包。这是Meteor的规范角色包。