简体   繁体   English

流星服务器在流星方法中使用 Accounts.addEmail() 引发错误

[英]Meteor server throws error with Accounts.addEmail() in a meteor method

I need help figuring out why I am getting this error.我需要帮助弄清楚为什么我会收到这个错误。

My method is defined in app/server/methods.js我的方法定义在app/server/methods.js

Meteor.methods({

    myMethod: function(user) {

        Accounts.addEmail(user._id, "thisemail@email.com", true); // set verified to true
    }
});

My template has an event that is calling this method from the client.我的模板有一个从客户端调用此方法的事件。

Template.myTemplate.events({

    'click #this-button': function(e) {

        Meteor.call("myMethod", userObject, function(error, result) {

            if (error) {
                console.log(error);
            } else {
                // do something here
            } 
        });
     }
});

I keep getting an Internal Server Error [500] error back to the console.我不断收到Internal Server Error [500]错误返回到控制台。 When I check my server output it says: Exception while invoking method 'myMethod' TypeError: Object #<Object> has no method 'addEmail' .当我检查我的服务器输出时,它说: Exception while invoking method 'myMethod' TypeError: Object #<Object> has no method 'addEmail'

Can anyone help me figure out why it can't be found/used?谁能帮我弄清楚为什么找不到/使用它?

These are the list of packages I am using, and I thought this came packaged with the accounts-password package according to the Meteor Documentation here .这些是我正在使用的软件包列表,我认为根据此处的 Meteor 文档,这是与帐户密码软件包一起打包的。

meteor-platform iron:core iron:router less zimme:iron-router-active tomi:upload-server tomi:upload-jquery houston:admin coffeescript alanning:roles edgee:slingshot joshowens:accounts-entry mystor:device-detection underscore email accounts-password

If I'm reading the commit history correctly, it looks like addEmail was added here as part of meteor 1.2.如果我正确阅读了提交历史记录,那么addEmail似乎是作为meteor 1.2 的一部分添加到此处的

The docs always reference the latest version, but your app is using version 1.1, which explains the missing function.文档始终引用最新版本,但您的应用程序使用的是 1.1 版,这解释了缺少的功能。

The solution may be as simple as running meteor update , however accounts-entry is ancient and it may be incompatible with meteor 1.2, as noted in this issue .解决方案可能就像运行meteor update一样简单,但是accounts-entry是古老的,它可能与meteor 1.2不兼容,如本期所述

If you can't or don't want to update, just leave a comment and I can suggest an alternative implementation.如果您不能或不想更新,请发表评论,我可以建议替代实施。

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

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