【问题标题】:verification email with accounts-google,accounts-facebook带有帐户-google、帐户-facebook 的验证电子邮件
【发布时间】:2016-03-15 09:43:47
【问题描述】:

我有正在运行的应用程序,它会在创建电子邮件/帐户名称时发送验证电子邮件,但如果我使用 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 也不起作用,因为它不在“电子邮件”中)

【问题讨论】:

    标签: meteor verification google-account


    【解决方案1】:

    我将 .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 .. 它奏效了;

    谢谢大家观看

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-23
      • 2023-04-05
      • 1970-01-01
      • 2014-05-17
      • 1970-01-01
      • 2014-01-04
      相关资源
      最近更新 更多