Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
meteor角色包,添加角色_Meteor_Meteor Accounts - Fatal编程技术网

meteor角色包,添加角色

meteor角色包,添加角色,meteor,meteor-accounts,Meteor,Meteor Accounts,目标是当创建用户时,有两个用户acc,一个应该有管理员,另一个是没有角色的普通用户。但是,当我登录acc谁应该得到管理员角色,我不能做的事情,我指定的acc与管理员角色。我遗漏了一些东西,我不知道是什么,提前感谢您提供的帮助。此代码中有多个错误: 首先,将用户设置为等于数组,然后检查它是否等于字符串。这将始终返回false 其次,Meteor.this.userId,应该是this.userId 第三,改变这一行: Meteor.publish(null, function (){ var u

目标是当创建用户时,有两个用户acc,一个应该有管理员,另一个是没有角色的普通用户。但是,当我登录acc谁应该得到管理员角色,我不能做的事情,我指定的acc与管理员角色。我遗漏了一些东西,我不知道是什么,提前感谢您提供的帮助。

此代码中有多个错误:

首先,将用户设置为等于数组,然后检查它是否等于字符串。这将始终返回false

其次,
Meteor.this.userId
,应该是
this.userId

第三,改变这一行:

Meteor.publish(null, function (){

var users = [ Meteor.users.find({})];
email="Osoba5@qwe.qwe";
if(users == email ){
    users = Meteor.this.userId;
    Roles.createRole('admin');
    Roles.setUserRoles(users, 'admin');
}else{
    users = Meteor.this.userId;
    Roles.createRole(['']);
    Roles.setUserRoles(users,['']);
}
return Meteor.users.find({});
});}
致:

var users = [ Meteor.users.find({})];
或:


感谢您帮助更正代码。我成功了
var users = Meteor.users.find({}); // users is a cursor
var users = Meteor.users.find({}).fetch(); // users is an array