【发布时间】:2016-01-21 20:06:41
【问题描述】:
我正在使用 Meteor 启动功能在服务器上创建默认用户。我想创建一个用户并在启动时验证他/她的电子邮件(我假设您只能在创建帐户后执行此操作)。
这是我所拥有的:
Meteor.startup(function() {
// Creates default accounts if there no user accounts
if(!Meteor.users.find().count()) {
// Set default account details here
var barry = {
username: 'barrydoyle18',
password: '123456',
email: 'myemail@gmail.com',
profile: {
firstName: 'Barry',
lastName: 'Doyle'
},
roles: ['webmaster', 'admin']
};
// Create default account details here
Accounts.createUser(barry);
Meteor.users.update(<user Id goes here>, {$set: {"emails.0.verified": true}});
}
});
正如我所说,我假设在将已验证标志设置为真之前必须先创建用户(如果此语句为假,请显示在创建用户时使标志为真的解决方案)。
为了将电子邮件验证标志设置为 true,我知道我可以在创建后使用 Meteor.users.update(userId, {$set: {"emails.0.verified": true}}); 更新用户。
我的问题是,我不知道如何获取我新创建的用户的用户 ID,我该怎么做?
【问题讨论】:
标签: meteor user-accounts creation email-verification