Is there a post createUser hook in meteor when using accounts-ui package?

后端 未结 6 1024
广开言路
广开言路 2020-12-03 06:58

Let\'s say I have a todo app, and I want to make sure that every user that registers has at least one todo to start with, something like \"First todo to cross off!\", how wo

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-03 07:40

    The Meteor API now has the hook onCreateUser:

    Accounts.onCreateUser(function (options, user) {
      Todos.insert({
        owner: user._id,
        text: "First todo to cross off!",
      });
    
      // We still want the default hook's 'profile' behavior.
      if (options.profile)
        user.profile = options.profile;
    
      return user;
    });
    

提交回复
热议问题