在 Meteor 中检查旧密码
Check old password in Meteor
我需要检查旧密码当用户想用 new.How 更改密码时,我可以做什么?
var oldpassword = template.$('#oldpassword').val();
var opt =Meteor.users.findOne({_id:Meteor.userId() });
if (opt.password!==oldpassword)
{
alert('Wrong old password');
return false;
}
Meteor 帐户包中的密码由 bcrypt 散列和加盐。因此 mongoDb 中的密码字段不会等于您示例中的旧密码。
你应该依赖包提供的方法:http://docs.meteor.com/#/full/accounts_changepassword
Accounts.changePassword(oldPassword, newPassword, function(err) {
if(err) {
alert('Wrong old password');
}
})
我需要检查旧密码当用户想用 new.How 更改密码时,我可以做什么?
var oldpassword = template.$('#oldpassword').val();
var opt =Meteor.users.findOne({_id:Meteor.userId() });
if (opt.password!==oldpassword)
{
alert('Wrong old password');
return false;
}
Meteor 帐户包中的密码由 bcrypt 散列和加盐。因此 mongoDb 中的密码字段不会等于您示例中的旧密码。
你应该依赖包提供的方法:http://docs.meteor.com/#/full/accounts_changepassword
Accounts.changePassword(oldPassword, newPassword, function(err) {
if(err) {
alert('Wrong old password');
}
})