简体   繁体   English

流星onCreateUser方法错误

[英]Meteor onCreateUser method error

I want an email to be sent to a user after they register for the site. 我希望用户注册该网站后将其发送给用户。 However, I keep getting the error: 但是,我不断收到错误:

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]

Here is my onCreateUser method: 这是我的onCreateUser方法:

Accounts.onCreateUser(function(options, user) {

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

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

Can someone help? 有人可以帮忙吗?

Thanks!! 谢谢!!

You'll want to look at the collection-hooks package to trigger code right after the user document has been created. 您将要查看收集挂钩包,以在创建用户文档后立即触发代码。 It's also useful for modifying the user document itself before it is stored. 这对于在存储用户文档之前修改用户文档本身也很有用。 Of course it can be used for any collection, not just users. 当然,它可以用于任何集合,而不仅仅是用户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM