0
我正在建立一個CMS,並根據用戶role
他們將能夠編輯/更新/刪除/創建不同的區域,但過濾了他們的role
在一個用戶與role: 'basic role'
不能刪除用戶與role: 'superuser'
可以。檢查用戶是否在流星中扮演角色的正確方法?
我目前所面對的是這樣的:
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的canonical _roles_包。 –