【问题标题】:How to conditionally skip sending e-mail verification in Meteor?如何有条件地跳过在 Meteor 中发送电子邮件验证?
【发布时间】:2013-06-09 22:01:55
【问题描述】:

我已经用sendVerificationEmail: true 配置了我的服务器,这是我在一般情况下想要的。但是,在某些情况下,我不希望 Meteor 发送验证电子邮件。相反,我想将电子邮件标记为以编程方式验证。

我已经尝试在 validateNewUser 挂钩中这样做

Accounts.validateNewUser(function(user) {
  user.emails[0].verified = true;
  return true;
});

在 onCreateUser 钩子中

Accounts.onCreateUser(function(options, user) {
  user.emails[0].verified = true;
  return user;
});

都没有成功。尽管电子邮件被标记为已验证,但 Meteor 仍会发送验证电子邮件。

【问题讨论】:

    标签: meteor


    【解决方案1】:

    通过sendVerificationEmail: false禁用自动电子邮件验证,并在您想要验证电子邮件的情况下手动执行

    var email = user.emails[0].address;
    Accounts.sendVerificationEmail(userId, email);
    

    【讨论】:

    • 这个问题是我不知道什么时候打电话给sendVerificationEmail。我无法在 onCreateUser 回调中执行此操作,因为该用户尚不存在(即我收到“错误:找不到用户”)。
    • 您可以在 onCreateUser 被调用后不久使用 Meteor.setTimeout(function() {sendVerification...}, 10000);onCreateUser 中调用
    猜你喜欢
    • 2016-02-16
    • 1970-01-01
    • 1970-01-01
    • 2019-10-18
    • 2019-11-25
    • 2014-04-03
    • 1970-01-01
    • 2019-03-09
    • 1970-01-01
    相关资源
    最近更新 更多