我在将自定义用户字段添加到流星用户对象(Meteor.user
)时遇到问题。我想要一个用户有一个“状态”字段,我宁愿不将它嵌套在“profile”(即profile.status)下,我知道默认情况下是r/w。 (我已经删除autopublish
。)将自定义字段添加到流星用户时遇到特权问题
我已经能够场发布到客户端就好了通过
Meteor.publish("directory", function() {
return Meteor.users.find({}, {fields: {username: 1, status: 1}});
});
...但我不能设置权限允许对日志 - 用户更新自己的status
。
如果我做
Meteor.users.allow({
update: function (userId) {
return true;
}});
在Models.js,
用户可以编辑每用户的所有领域。这并不酷。
我试着做变体,如
Meteor.users.allow({
update: function (userId) {
return userId === Meteor.userId();
}});
和
Meteor.users.allow({
update: function (userId) {
return userId === this.userId();
}});
,他们只是在控制台中我拒绝访问错误。
这个有点documentation addresses,但没有详细说明。我在犯什么愚蠢的错误?
(这类似于this SO问题,但这个问题只解决如何发布领域,而不是如何对其进行更新。)
它不适合我...... userData代表什么? –