mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
🐛 fix changePassword bug (#7590)
no issue - comparison for isLoggedInUser did not work when userId was a string - parsing of int was missing
This commit is contained in:
parent
8bcd000829
commit
02a1f08ba3
2 changed files with 15 additions and 1 deletions
|
@ -683,7 +683,7 @@ User = ghostBookshelf.Model.extend({
|
|||
ne2Password = object.ne2Password,
|
||||
userId = parseInt(object.user_id),
|
||||
oldPassword = object.oldPassword,
|
||||
isLoggedInUser = object.user_id === options.context.user,
|
||||
isLoggedInUser = userId === options.context.user,
|
||||
user;
|
||||
|
||||
// If the two passwords do not match
|
||||
|
|
|
@ -560,6 +560,20 @@ describe('User Model', function run() {
|
|||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('wrong old password', function (done) {
|
||||
UserModel.changePassword({
|
||||
newPassword: '12345678',
|
||||
ne2Password: '12345678',
|
||||
oldPassword: '123456789',
|
||||
user_id: '1'
|
||||
}, testUtils.context.owner).then(function () {
|
||||
done(new Error('expected error!'));
|
||||
}).catch(function (err) {
|
||||
(err instanceof errors.ValidationError).should.eql(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('success', function () {
|
||||
|
|
Loading…
Add table
Reference in a new issue