【问题标题】:Meteorjs Accounts.config sendVerificationEmail option doesn't have any effectMeteorjs Accounts.config sendVerificationEmail 选项没有任何效果
【发布时间】:2019-12-22 04:04:03
【问题描述】:

我正在创建没有accounts.ui 包的帐户,只使用accounts-base/accounts-password。我在server 一侧有一个代码

Accounts.config({
  sendVerificationEmail: true,
  forbidClientAccountCreation: true // cause we call it from server code
});

然后在提交注册表单时我调用

Accounts.createUser({User account document where `email` field is set to actual email}); 

它创建用户(我稍后可以使用此用户登录)没有问题或错误,除非它不向我发送任何电子邮件。

我安装了流星电子邮件包,但我没有配置电子邮件 URL,因此它应该在标准输出中打印不会发生的消息。

我可以使用 post user create hook 并手动发送电子邮件,但我想它应该可以在没有文档中描述的额外工作的情况下工作。

Meteor 版本是 1.0.3.1

【问题讨论】:

    标签: meteor-accounts meteor


    【解决方案1】:

    我面临同样的问题,但它适用于我拥有的不同项目。 有一种解决方法是使用钩子 (https://github.com/Meteor-Community-Packages/meteor-collection-hooks)。

    使用meteor add matb33:collection-hooks添加包

    然后在服务端导入import { CollectionHooks } from 'meteor/matb33:collection-hooks';

    最后,您可以在 Meteor.starup 中添加以下代码:

    Meteor.users.after.insert((userId, doc) => {
        Accounts.sendVerificationEmail(doc._id);
    });
    

    我也尝试在 Accounts.onCreateUser 上发送电子邮件验证,但是,似乎该用户尚未存储在数据库中,因此失败了。

    使用 Meteor 1.8.3。

    更新:阅读代码后,我发现 sendVerificationEmail 仅在用户在客户端注册时才有效(这不是您的情况,也不是我的情况,因为我们都禁止这样做)。

    您可以检查 account_commons.js 并检查他们是否对此发表了评论:

    // - sendVerificationEmail {Boolean}
    //     Send email address verification emails to new users created from
    //     client signups.
    

    现在你可以放心地继续使用你的钩子了。

    【讨论】:

      【解决方案2】:

      按照这一步一步操作应该可以帮助您:

      https://gentlenode.com/journal/meteor-20-verify-an-email-with-meteor-accounts/42

      【讨论】:

      • 问题是如何在没有 post hook 的情况下使用内置功能。提供的解决方案是钩子一。不管怎样,我会用它。
      • 我认为您的链接已损坏,我无法加载。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-06-14
      • 2019-06-19
      • 2017-07-18
      • 2010-10-17
      • 2012-11-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多