如何手动将用户添加到Meteor.users集合?

时间:2016-11-27 07:59:23

标签: mongodb meteor meteor-accounts

我有超级用户,我手动添加,这个用户可以通过我给他的表格手动其他用户。

假设我保存用户输入的输入,如下所示的代码:

$(document).on("click", "li a", function(e) {
    var id = $(this).attr("title");
    e.preventDefault();
    console.log("MyApp working..." + id);
});

在检查电子邮件和用户名中是否没有匹配后,如何将这些值存储在Meteor.users中的这些会话中?

如何在将密码存储到我的数据库之前加密密码?

1 个答案:

答案 0 :(得分:2)

从客户端调用此代码时:

Meteor.call('createUser','someemail@gmail.com','password123',function(err,res){
  .....
})

在Meteor.users集合中创建一个用户,其方法

中给出了id
Meteor.methods({
  createUser(email,password){
    check(email,String);
    check(password,String);    
    let id = Accounts.createUser({
      email: email,
      password: password,
      profile: {} //anything you like to add to profile.
    })    
  }
})