2020-03-09 08:00:03 +00:00
|
|
|
|
|
|
|
module.exports = Self => {
|
|
|
|
Self.remoteMethod('changePassword', {
|
|
|
|
description: 'Changes the user password',
|
|
|
|
accepts: [
|
|
|
|
{
|
|
|
|
arg: 'id',
|
2022-06-02 07:01:34 +00:00
|
|
|
type: 'number',
|
2020-03-09 08:00:03 +00:00
|
|
|
description: 'The user id',
|
|
|
|
http: {source: 'path'}
|
|
|
|
}, {
|
|
|
|
arg: 'oldPassword',
|
2022-06-02 07:01:34 +00:00
|
|
|
type: 'string',
|
2020-03-09 08:00:03 +00:00
|
|
|
description: 'The old password',
|
|
|
|
required: true
|
|
|
|
}, {
|
|
|
|
arg: 'newPassword',
|
2022-06-02 07:01:34 +00:00
|
|
|
type: 'string',
|
2020-03-09 08:00:03 +00:00
|
|
|
description: 'The new password',
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
],
|
|
|
|
http: {
|
|
|
|
path: `/:id/changePassword`,
|
|
|
|
verb: 'PATCH'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-09-21 11:24:43 +00:00
|
|
|
Self.changePassword = async function(id, oldPassword, newPassword) {
|
|
|
|
await Self.rawSql(`CALL account.user_changePassword(?, ?, ?)`,
|
|
|
|
[id, oldPassword, newPassword]);
|
|
|
|
await Self.app.models.UserAccount.syncById(id, newPassword);
|
2020-03-09 08:00:03 +00:00
|
|
|
};
|
|
|
|
};
|