【问题标题】:Check old password in Meteor [duplicate]检查 Meteor 中的旧密码 [重复]
【发布时间】:2015-10-08 07:41:46
【问题描述】:

当用户想用新密码更改密码时,我需要检查旧密码。我该怎么做?

 var oldpassword = template.$('#oldpassword').val();
 var opt =Meteor.users.findOne({_id:Meteor.userId() });
  if (opt.password!==oldpassword) 
   {
    alert('Wrong old password');
    return false;
   }

【问题讨论】:

    标签: meteor change-password


    【解决方案1】:

    Meteor 帐户包中的密码由 bcrypt 散列和加盐。因此,mongoDb 中的密码字段将不等于您示例中的 oldpassword。

    你应该依赖包提供的方法:http://docs.meteor.com/#/full/accounts_changepassword

    Accounts.changePassword(oldPassword, newPassword, function(err) {
      if(err) {
        alert('Wrong old password');
      }
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-16
      • 2014-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-10
      • 2023-04-06
      • 2016-01-06
      相关资源
      最近更新 更多