如何在流星种子期间创建经过验证的帐户

How to create verified account during meteor seed

我必须在做种时创建一个经过验证的帐户。下面的用户对象创建 user.email[0].verified = 'false' 但它应该在 true.

user = {
  name: 'Admin',
  email: 'admin@example.com',
  password: 'password',
}
Meteor.startup(function() {
 if (Meteor.users.find().count() < 2) {
      Accounts.createUser(user); // It create user verification as false. How to make them true
 }
});

我尝试了下面的对象,但没有用。

user = {
  name: 'Admin',
  email: [address:'admin@example.com',verified:true],
  password: 'password',
}

流星包:

accounts-password
ian:accounts-ui-bootstrap-3

似乎 Accounts.addEmail 允许以编程方式设置 已验证 属性。根据文档,如果用户已经注册了该电子邮件,它应该覆盖这些设置。值得一试

Accounts.addEmail(userId, newEmail, [verified])

http://docs.meteor.com/#/full/Accounts-addEmail

在你的情况下(在服务器上):

user = {
  name: 'Admin',
  email: 'admin@example.com',
  password: 'password',
}
Meteor.startup(function() {
  if (Meteor.users.find().count() < 2) {
    userId = Accounts.createUser(user);
    Accounts.addEmail(userId, user.email, true);
  }
});