Meteor onCreateUser方法错误

时间:2015-07-30 02:45:47

标签: javascript meteor accounts

我希望在用户注册该网站后将电子邮件发送给用户。但是,我一直收到错误:

I20150729-22:44:52.253(-4)? Exception while invoking method 'entryCreateUser' Error: Match error: Expected string, got undefined in field [0]
I20150729-22:44:52.254(-4)?     at checkSubtree (packages/check/match.js:159:1)
I20150729-22:44:52.255(-4)?     at packages/check/match.js:206:1
I20150729-22:44:52.255(-4)?     at Array.forEach (native)
I20150729-22:44:52.255(-4)?     at Function._.each._.forEach (packages/underscore/underscore.js:105:1)
I20150729-22:44:52.255(-4)?     at checkSubtree (packages/check/match.js:204:1)
I20150729-22:44:52.255(-4)?     at check (packages/check/match.js:32:1)
I20150729-22:44:52.255(-4)?     at [object Object].Meteor.methods.sendEmail (app/server/methods/email.js:3:5)
I20150729-22:44:52.255(-4)?     at maybeAuditArgumentChecks (packages/ddp/livedata_server.js:1617:1)
I20150729-22:44:52.255(-4)?     at packages/ddp/livedata_server.js:1530:1
I20150729-22:44:52.255(-4)?     at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
I20150729-22:44:52.256(-4)? Sanitized and reported to the client as: Match failed [400]

这是我的onCreateUser方法:

Accounts.onCreateUser(function(options, user) {

        var userEmail = user.email
        var emailSubject = "Welcome to Company!";
        var emailBody = "SUP";

         Meteor.call('sendEmail',
                        userEmail,
                        '',
                        '',
                        emailSubject,
                        emailBody
                      );
    });

有人可以帮忙吗?

谢谢!

1 个答案:

答案 0 :(得分:1)

您需要查看collection-hooks package以在创建用户文档后立即触发代码。在存储之前修改用户文档本身也很有用。当然,它可以用于任何集合,而不仅仅是用户。