Javascript Accounts.createUser在Meteor.methods中使用时不发送验证电子邮件

Javascript Accounts.createUser在Meteor.methods中使用时不发送验证电子邮件,javascript,meteor,meteor-accounts,meteor-helper,Javascript,Meteor,Meteor Accounts,Meteor Helper,我有一个基本的meteor方法,它可以做到以下几点 server/methods.js Meteor.methods({ createUserAccount: function(user) { return Accounts.createUser(user); } }); server/init.js Meteor.startup(function() { process.env.MAIL_URL = ""//removed for SO; Account

我有一个基本的meteor方法,它可以做到以下几点

server/methods.js

Meteor.methods({
  createUserAccount: function(user) {
    return Accounts.createUser(user);
    }
});
server/init.js

Meteor.startup(function() {
    process.env.MAIL_URL = ""//removed for SO;

    Accounts.config({
        sendVerificationEmail:true,
        forbidClientAccountCreation: true 
    });
)};
从客户端,注册被这样调用

client/register.js

'submit #app-register-user': function(e,t){
        e.preventDefault();
        var user = {
            username: t.find('#app-username').value,
            email: t.find('#app-email').value,
            password: t.find('#app-password').value,
            profile:{
                name: t.find('#app-username').value
            }
        };
        Meteor.call('createUserAccount', user, function(error) {
            if(error){
                alert(error);
            }
            else{
                $("#joinModal").modal("hide");
            }
        });
}
Accounts.createUser({
        username: t.find('#app-username').value,
        email: t.find('#app-email').value,
        password: t.find('#app-password').value,
        profile:{
            name: t.find('#app-username').value
        }
    },function(err){
        if(err){
            alert("something went wrong "+ err);
        }
        else{
            $("#joinModal").modal("hide");
        }
})
这会创建用户,但不会发送验证电子邮件。但是如果我像这样从客户端创建用户

client/register.js

'submit #app-register-user': function(e,t){
        e.preventDefault();
        var user = {
            username: t.find('#app-username').value,
            email: t.find('#app-email').value,
            password: t.find('#app-password').value,
            profile:{
                name: t.find('#app-username').value
            }
        };
        Meteor.call('createUserAccount', user, function(error) {
            if(error){
                alert(error);
            }
            else{
                $("#joinModal").modal("hide");
            }
        });
}
Accounts.createUser({
        username: t.find('#app-username').value,
        email: t.find('#app-email').value,
        password: t.find('#app-password').value,
        profile:{
            name: t.find('#app-username').value
        }
    },function(err){
        if(err){
            alert("something went wrong "+ err);
        }
        else{
            $("#joinModal").modal("hide");
        }
})
电子邮件会被发送出去

我之所以尝试从服务器端创建用户,是因为我想禁用自动登录并允许经过验证的用户登录

任何关于如何解决这个问题的帮助都将不胜感激


谢谢。

如果您创建了用户客户端,Accounts包将负责在Meteor.users集合中创建用户,然后发送验证电子邮件。 它通过调用服务器方法
createUser
来实现

如果像您这样使用自己的方法创建新的用户服务器端,Accounts包只创建用户。您必须按照richsilv的建议亲自发送验证电子邮件。或者使用其他一些例行程序将您的验证电子邮件发送给用户


如果您想了解Accounts软件包如何处理此问题,请查看:

只需使用@richsilv感谢您的回复,您能否提供一个示例?嗨@Jos谢谢您的回复。你能提供一个我如何使用发送验证包的例子吗?在你的服务器/methods.js:Meteor.methods({createUserAccount:function(user){var userId=Accounts.createUser(user);if(userId)Accounts.sendVerificationEmail(userId);return userId;});哇,真管用!非常感谢。只是一个简单的问题,你是如何知道帐户的;返回用户ID?它没有提到,在文档中,Accounts软件包中的这一行显示:如果这对您有效,请不要忘记接受答案:)