子类化 Meteor.users() 以获得不同的用户类型

Subclassing Meteor.users() to get different user types

本文关键字:类型 用户 Meteor users 子类      更新时间:2023-09-26

在 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
}

似乎您必须创建一个用户才能发送注册电子邮件。

有没有办法创建配置文件并将配置文件注册到注册链接上的新用户?

Accounts.onCreateUser 在您创建新用户后立即运行。

要拥有多种类型的用户,可以使用流星角色包。

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']);
});