Meteor-添加用户自定义字段的方法不起作用
Meteor - Method adding user custom field do not work
我正试图通过一个方法向Meteor.Users添加一个自定义的"isContributor"字段,但不知怎么的,它没有添加该字段。(我甚至在对谁可以进行此更新进行任何安全检查之前就已经在谈论了)。
在客户端,我有以下事件:
Template.Articles.events({
'click #BeContributor': function() {
userId = Meteor.userId();
Meteor.call('setContributorState', userId);
}
});
和在server/main.js中如下:
Meteor.methods({
setContributorState: function(userId) {
Meteor.users.update(userId, {
$set: {
isContributor: true
}
});
}
});
不知怎的,它没有为我的用户添加字段。没有控制台或服务器错误。我想我错过了一些关于场地加法的权利。有什么想法吗?
提前谢谢。
---编辑---
事实上,这个方法是有效的,但我没有公布结果,所以我无法在MeteorToys中检查该字段是否已更新。以下出版物有效:
Meteor.publish(null, function(){
return Meteor.users.find({_id: this.userId}, {fields: {isContributor: 1}});
});
在发布自定义Meteor.user()字段
p>如果要修改登录用户的贡献者状态,则不需要传递任何参数。这是一个安全漏洞。服务器具有调用请求的信息。Meteor.methods({
setContributorState: function() {
Meteor.users.update({_id:this.userId}, {
$set: {
isContributor: true
}
});
}
});
相关文章:
- Meteor-添加用户自定义字段的方法不起作用
- 在 JQUERY 中创建 HTML 后,Jquery 方法不起作用
- 为什么这个扩展方法不起作用
- Splice()方法不起作用
- Angularjs-向工厂传递数据的方法不起作用
- Knockout和bread.js的take方法不起作用Paging
- javascript注入$http-post方法不起作用
- 为什么pulk()和where()方法不起作用
- Ajax get 方法不起作用
- 当我将javascript代码放在外部站点.js文件中时,Ajax页面方法不起作用
- getJSON 方法不起作用
- Jquery ajax get 方法不起作用
- jQuery AddClass 方法不起作用
- ScriptManager.RegisterStartupScript() 方法不起作用 - ASP.NET,C#
- 为什么JavaScript方法不起作用
- 为什么 findRandom() mongoose for node.js 方法不起作用
- BackboneJS的设置方法不起作用
- 从javascript调用 asp.net 页面方法不起作用
- 主干.js对以前的方法不起作用进行建模
- toExponential() 方法不起作用