【问题标题】:User Not Found when trying to reset password尝试重置密码时未找到用户
【发布时间】:2016-08-04 16:46:26
【问题描述】:

我有一个用户忘记了密码。使用 Accounts 包,用户尝试使用“重置密码”功能重置密码。当他们输入他们的电子邮件地址时,它会显示“未找到用户”。

这是什么原因造成的?更重要的是我该如何解决它?我一直在努力寻找解决方案,所以任何帮助都会很棒。我尝试复制,但我的测试帐户没有同样的问题。

我的版本是带有 accounts-password 和 accounts-base 包的 Meteor 1.2。我的设置是:

passwordSignupFields: "USERNAME_AND_EMAIL"

【问题讨论】:

  • 用户是否存在?会不会是区分大小写的问题?

标签: meteor meteor-accounts


【解决方案1】:

重置用户密码时,Meteor 会尝试通过提供的电子邮件查找用户。如果它无法使用电子邮件找到用户 - 它会抛出“找不到用户” - 链接到代码 here

Meteor.methods({forgotPassword: function (options) {
  check(options, {email: String});

  var user = Accounts.findUserByEmail(options.email);
  if (!user)
    throw new Meteor.Error(403, "User not found");

  const emails = _.pluck(user.emails || [], 'address');
  const caseSensitiveEmail = _.find(emails, email => {
    return email.toLowerCase() === options.email.toLowerCase();
  });

  Accounts.sendResetPasswordEmail(user._id, caseSensitiveEmail);
}});

用户是否提供了正确的电子邮件?检查所提供的电子邮件是否确实存在于Meteor.users 集合中的数据库中

【讨论】:

  • 看来他使用了 Google/G+ 登录功能。我会看看能不能让他再试一次。
猜你喜欢
  • 2019-11-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多