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

时间:2014-03-26 03:18:18

标签: meteor account

我正在尝试在创建用户的个人资料时添加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;
});

这两个字段未添加,我在Console中收到此错误。

Uncaught TypeError: Object #<Object> has no method 'onCreateUser' 

我做错了什么?

1 个答案:

答案 0 :(得分:7)

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