Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Meteor发送验证电子邮件导致错误_Meteor_Meteorite - Fatal编程技术网

使用Meteor发送验证电子邮件导致错误

使用Meteor发送验证电子邮件导致错误,meteor,meteorite,Meteor,Meteorite,我有以下资料: Template.joinTemplate.events({ "submit #Signup-Form": function(event, template) { event.preventDefault(); var email = template.find('#Email').value; Accounts.createUser({ username: template.find('#Email').value, em

我有以下资料:

Template.joinTemplate.events({
"submit #Signup-Form": function(event, template) {
    event.preventDefault();
    var email = template.find('#Email').value;
    Accounts.createUser({
        username: template.find('#Email').value,
        emails: {
            address: template.find('#Email').value
        },
        password: template.find('#Password').value,
        profile: {
            firstname: template.find("#Firstname").value,
            lastname: template.find("#Lastname").value

        }
    }, function(error) {
        if (error) {
            // Deal with errors
        } else {
            Accounts.sendVerificationEmail(this.userId, email);
            Router.go('/');

        }
    });
}
});
但会出现以下错误:

 Error logging in with token: Error: You've been logged out by the server. Please login again. [403] debug.js:41
Exception in delivering result of invoking 'createUser': TypeError: Object #<Object> has no method 'sendVerificationEmail'
    at http://localhost:3000/client/views/application/authentication/join_template.js?0ca175e5dc0f3b4596ed33e260d5636f8f9cc69b:28:26
    at http://localhost:3000/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:801:19
    at loggedInAndDataReadyCallback (http://localhost:3000/packages/accounts-base.js?efdcc57c69f7e2ccbb61f1e963da216b1729ac72:455:5)
    at null._callback (http://localhost:3000/packages/meteor.js?2b578107b8239ff9bc64200e6af2a24001461b30:801:22)
    at _.extend._maybeInvokeCallback (http://localhost:3000/packages/livedata.js?418d88f2513ae6bf0ff1447759a5c590923456bd:3502:12)
    at _.extend.receiveResult (http://localhost:3000/packages/livedata.js?418d88f2513ae6bf0ff1447759a5c590923456bd:3522:10)
    at _.extend._livedata_result (http://localhost:3000/packages/livedata.js?418d88f2513ae6bf0ff1447759a5c590923456bd:4452:9)
    at onMessage (http://localhost:3000/packages/livedata.js?418d88f2513ae6bf0ff1447759a5c590923456bd:3376:12)
    at http://localhost:3000/packages/livedata.js?418d88f2513ae6bf0ff1447759a5c590923456bd:2705:11
    at Array.forEach (native) 
使用令牌登录时出错:错误:您已被服务器注销。请重新登录。[403]debug.js:41
传递调用“createUser”的结果时出现异常:TypeError:对象#没有方法“sendVerificationEmail”
在http://localhost:3000/client/views/application/authentication/join_template.js?0ca175e5dc0f3b4596ed33e260d5636f8f9cc69b:28:26
在http://localhost:3000/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:801:19
在loggedInAndDataReadyCallback(http://localhost:3000/packages/accounts-base.js?efdcc57c69f7e2ccbb61f1e963da216b1729ac72:455:5)
在null处。\u回调(http://localhost:3000/packages/meteor.js?2b578107b8239ff9bc64200e6af2a24001461b30:801:22)
在uu.extend.u可能会被取消(http://localhost:3000/packages/livedata.js?418d88f2513ae6bf0ff1447759a5c590923456bd:3502:12)
在uuu.延期接收结果(http://localhost:3000/packages/livedata.js?418d88f2513ae6bf0ff1447759a5c590923456bd:3522:10)
在u.extend._livedata_结果(http://localhost:3000/packages/livedata.js?418d88f2513ae6bf0ff1447759a5c590923456bd:4452:9)
在网上留言(http://localhost:3000/packages/livedata.js?418d88f2513ae6bf0ff1447759a5c590923456bd:3376:12)
在http://localhost:3000/packages/livedata.js?418d88f2513ae6bf0ff1447759a5c590923456bd:2705:11
at Array.forEach(本机)
我已安装了所有帐户库、帐户ui和帐户密码

不确定我做错了什么:(

如您所知,
帐户。sendVerificationEmail
仅在服务器上可用,您正试图在客户端上使用它

我不确定您是否可以使用
帐户。onCreateUser
功能发送验证电子邮件:在该功能中,用户尚未添加到
Meteor.users
集合,我猜
帐户。sendVerificationEmail
要求用户加入该集合。我不知道解决此问题的最佳方法,但您可以始终使用光标选择所有用户,然后观察添加到集合中的用户(尽管这不是一个好的解决方案)


仅在函数中使用
sendVerificationEmail
字段是不够的?

谢谢你,Peppe。我错过了显而易见的。你介意解释一下我如何将新创建的用户Id传递给sendVerificationEmail吗?例如,如果我输入“Meteor.call('VerifyEmail'),\u Id?