验证电子邮件与account-google,accounts-facebook

时间:2016-03-15 09:43:47

标签: meteor verification google-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
    });
};

请告诉我,如果您在google登录的情况下我应该把... services.google.email放在哪里,对于Facebook来说也是如此...

换句话说,我如何向Meteor.user()。services.google.email发送验证邮件..(甚至回忆起带有该电子邮件的sendUserVerificationEmail不起作用,因为它不在'电子邮件'中)

1 个答案:

答案 0 :(得分:0)

我修改了.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 ..它工作正常;

谢谢大家看看