包含 accounts-google,accounts-facebook 的验证邮件

verification email with accounts-google,accounts-facebook

我有 运行 应用程序,它会在创建 email/account 名称时发送验证电子邮件,但如果我使用 google/facebook 登录,它不会发送验证电子邮件;这可能是由于 services.google.email 中的电子邮件地址;如果 Accounts.emailTemplates 中存在字段 'to',我该如何设置它。

configureAccounts = function() {
    setMailVerification(enableMailVerification);
};

setMailVerification = function() {
    Accounts.emailTemplates.from = 'myEmail@.com';
    Accounts.emailTemplates.verifyEmail = {
        subject : function(user) {
            return "Confirmation"
        },
        text : function(user, url) {
            var greeting = (user.profile && user.profile.nick) ? ("Hello " + user.profile.nick + ",") : "Hello,";
            return greeting + 
                "\n\n"  + "Thank you for registration."+
                "\n"    + "To confirm click the following link:" + url +
                "\n\n"  + "thank you."
        }
    };

    Accounts.config({
        sendVerificationEmail : true,
        forbidClientAccountCreation : false
    });
};

如果你应该把我放在哪里,请告诉我...services.google.email 如果 google 登录,同样适用于 facebook...

换句话说,我如何将验证电子邮件发送到 Meteor.user()。services.google.email ..(即使使用该电子邮件回忆 sendUserVerificationEmail 也不起作用,因为它不在 'emails' )

我修改了.email 属性 onCreateUser 如下:

if(user.services != undefined) {
    console.log('services in onCreateUser');
    user.sentVerificationEmail = false;
    user.emails =[];

    var emailServices = user.services.google != undefined ?
        user.services.google.email :
        user.services.facebook.email;
    user.emails.push({
        address : emailServices,
        verified : false
    });
}

if (options.profile)
    user.profile = options.profile;

return user;

然后我调用了 Accounts.sentVerificationEmail 然后是 onLogin .. 它起作用了;

谢谢大家的观看