Meteor 服务器在 meteor 方法中抛出 Accounts.addEmail() 错误

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

本文关键字:addEmail Accounts 错误 服务器 meteor 方法 Meteor      更新时间:2023-09-26

我需要帮助弄清楚为什么会出现此错误。

我的方法在 app/server/methods.js 中定义

Meteor.methods({
    myMethod: function(user) {
        Accounts.addEmail(user._id, "thisemail@email.com", true); // set verified to true
    }
});

我的模板有一个从客户端调用此方法的事件。

Template.myTemplate.events({
    'click #this-button': function(e) {
        Meteor.call("myMethod", userObject, function(error, result) {
            if (error) {
                console.log(error);
            } else {
                // do something here
            } 
        });
     }
});

我不断收到Internal Server Error [500]错误返回到控制台。当我检查我的服务器输出时,它说: Exception while invoking method 'myMethod' TypeError: Object #<Object> has no method 'addEmail' .

谁能帮我弄清楚为什么找不到/使用它?

这些是我正在使用的软件包列表,我认为根据这里的 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

如果我正确阅读了提交历史记录,看起来addEmail是作为meteor 1.2的一部分添加在此处的。

文档始终引用最新版本,但您的应用使用的是版本 1.1,这解释了缺少的功能。

解决方案可能像运行meteor update一样简单,但是accounts-entry是古老的,它可能与流星1.2不兼容,如本期所述。

如果您不能或不想更新,只需发表评论,我可以建议替代实现。