Meteor用户电子邮件验证不验证电子邮件

时间:2014-04-30 16:02:06

标签: mongodb email meteor

我创建用户注册并在用户收到的电子邮件中发送验证电子邮件:

Hello Derp,
To verify your account email, simply click the link below.
http://sijie.meteor.com/#/verify-email/pd65W2yQ8tKTd6XbF
Thanks.

点击该链接后,我认为必须验证电子邮件地址,但我检查mongo,仍然验证:false

"emails" : [
        {
            "address" : "derp@yahoo.com",
            "verified" : false
        }
    ],

为什么会这样?点击链接后如何验证用户?

感谢

2 个答案:

答案 0 :(得分:3)

如果您使用的是account-ui或accounts-ui-unstyled软件包,则网址会自动生效。否则,您必须使用存储在客户端的Accounts._verifyEmailToken中的令牌调用Accounts.verifyEmail。 / p>

他们在帐户中执行此操作ui是检查启动时是否存在Accounts._verifyEmailToken,如果存在则调用Accounts.verifyEmail。

自: https://github.com/meteor/meteor/blob/4d45f2426057d882a225fe7fc57eba45f1d4cd26/packages/accounts-ui-unstyled/login_buttons_dialogs.js#L23

Meteor.startup(function () {
  if (Accounts._verifyEmailToken) {
    Accounts.verifyEmail(Accounts._verifyEmailToken, function(error) {
      Accounts._enableAutoLogin();
      if (!error)
        loginButtonsSession.set('justVerifiedEmail', true);
      // XXX show something if there was an error.
    });
  }
});

答案 1 :(得分:0)

您可能需要手动使用此方法:Accounts.verifyEmail
如果您使用IronRouter,则可以在onBeforeAction中执行此操作。