1

我正在创建没有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 并手动发送电子邮件,但我想它应该可以在没有文档中描述的额外工作的情况下工作。

流星版本是 1.0.3.1

4

2 回答 2

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 上发送电子邮件验证,但是,似乎用户尚未存储在数据库中,因此失败了。

使用流星 1.8.3。

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

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

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

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

于 2019-12-21T17:36:40.003 回答
0

遵循此一步一步应该可以帮助您:

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

于 2015-02-07T08:33:37.720 回答