This commit is contained in:
parent
ddab59a10c
commit
c35e2e155f
|
@ -125,14 +125,14 @@ module.exports = function(Self) {
|
|||
|
||||
try {
|
||||
await Self.rawSql(`CALL account.user_setPassword(?, ?)`, [id, newPassword], options);
|
||||
await _setPassword.call(this, id, newPassword, options, options);
|
||||
await _setPassword.call(this, id, newPassword, options, cb);
|
||||
const user = await Self.findById(id, null, options);
|
||||
await user.updateAttribute('passExpired', null, options);
|
||||
if (tx) await tx.commit();
|
||||
return;
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
console.error('Error changing password, contact with informatica', e);
|
||||
// console.error('Error changing password, contact with informatica', e);
|
||||
throw new UserError(e);
|
||||
}
|
||||
};
|
||||
|
@ -154,14 +154,14 @@ module.exports = function(Self) {
|
|||
|
||||
try {
|
||||
await Self.rawSql(`CALL account.user_changePassword(?, ?, ?)`, [id, oldPassword, newPassword], options);
|
||||
await _changePassword.call(this, id, oldPassword, newPassword, options);
|
||||
await _changePassword.call(this, id, oldPassword, newPassword, options, cb);
|
||||
const user = await Self.findById(id, null, options);
|
||||
await user.updateAttribute('passExpired', null, options);
|
||||
if (tx) await tx.commit();
|
||||
return;
|
||||
} catch (error) {
|
||||
if (tx) await tx.rollback();
|
||||
console.error('Error changing password, contact with informatica', error);
|
||||
// console.error('Error changing password, contact with informatica', error);
|
||||
throw new UserError(error.sqlMessage || 'Error changing password, contact with informatica');
|
||||
}
|
||||
};
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
"type": "number",
|
||||
"id": true
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"username": {
|
||||
"type": "string",
|
||||
"mysql": {
|
||||
|
@ -38,6 +42,9 @@
|
|||
"lang": {
|
||||
"type": "string"
|
||||
},
|
||||
"bcryptPassword": {
|
||||
"type": "string"
|
||||
},
|
||||
"active": {
|
||||
"type": "boolean"
|
||||
},
|
||||
|
|
|
@ -28,7 +28,6 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.changePassword = async function(id, oldPassword, newPassword) {
|
||||
const response = await Self.app.models.VnUser.changePassword(id, oldPassword, newPassword);
|
||||
console.log(response);
|
||||
await Self.app.models.VnUser.changePassword(id, oldPassword, newPassword);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
fdescribe('account changePassword()', () => {
|
||||
fit('should throw an error when old password is wrong', async() => {
|
||||
let err;
|
||||
await models.Account.changePassword(1, 'wrongPassword2', 'nightmare.9999')
|
||||
.catch(error => {
|
||||
err = error.sqlMessage;
|
||||
});
|
||||
describe('account changePassword()', () => {
|
||||
it('should throw an error when old password is wrong', async() => {
|
||||
let error;
|
||||
try {
|
||||
await models.Account.changePassword(1, 'wrongPassword', 'nightmare.9999');
|
||||
} catch (e) {
|
||||
error = e.message;
|
||||
}
|
||||
|
||||
expect(err).toEqual('Invalid password');
|
||||
expect(error).toContain('Invalid password');
|
||||
});
|
||||
|
||||
it('should change password', async() => {
|
||||
|
|
Loading…
Reference in New Issue