在meteor中,数据库中有Meteor.users
个集合。我想要几种不同类型的用户,我想要很多相同的方法
// after creating a user profile and sending an email to confirm profile
enrollUser: function(id) {
var profile = MyCollection.findOne(id);
// send enrollment email
// when user confirms email and sets a password, they are registered as a user.
// `profile` is added as the `user.profile`, with the email in `profile` registered
}
您似乎必须创建用户才能发送注册电子邮件。
有没有办法在注册链接上创建配置文件并将配置文件注册到新用户?
答案 0 :(得分:1)
Accounts.onCreateUser在您创建新用户后立即运行。
要拥有多种类型的用户,您可以使用meteor roles package。
Accounts.onCreateUser( function(options, user) {
//carry over any profile information resulting from the sign-up method (google, etc)
if (options.profile) user.profile = options.profile;
//send your email here
//add special role
Roles.addUsersToRoles(user, ['special-user']);
});