为什么Meteor.Accounts会返回"没有方法'onCreateUser'"?

Chr*_*ris 4 account meteor

我正在尝试在创建用户的个人资料时添加accountActive和accountExpirationDate.根据我读过的所有内容,我应该使用Accounts.onCreateUser,如下所示:

// Add accountActive and accountExpirationDate
Accounts.onCreateUser(function(options, user) {
  if (options.profile) {
    user.profile = options.profile;
    user.profile.accountActive          =   false;
    user.profile.accountExpirationDate  =   null;
  }
  return user;
});
Run Code Online (Sandbox Code Playgroud)

这两个字段没有添加,我在Console中收到此错误.

Uncaught TypeError: Object #<Object> has no method 'onCreateUser' 
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

Chr*_*ris 7

问题是Accounts.onCreateUser正在客户端文件夹中运行.它不能在客户端中运行,只能在服务器上运行.