2020-03-09 08:00:03 +00:00
|
|
|
module.exports = Self => {
|
|
|
|
Self.remoteMethod('setPassword', {
|
|
|
|
description: 'Sets the user password',
|
2023-04-03 06:54:15 +00:00
|
|
|
accessType: 'WRITE',
|
2020-03-09 08:00:03 +00:00
|
|
|
accepts: [
|
|
|
|
{
|
|
|
|
arg: 'id',
|
2022-06-16 09:32:42 +00:00
|
|
|
type: 'number',
|
2020-03-09 08:00:03 +00:00
|
|
|
description: 'The user id',
|
|
|
|
http: {source: 'path'}
|
|
|
|
}, {
|
|
|
|
arg: 'newPassword',
|
2022-06-16 09:32:42 +00:00
|
|
|
type: 'string',
|
2020-03-09 08:00:03 +00:00
|
|
|
description: 'The new password',
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
],
|
|
|
|
http: {
|
|
|
|
path: `/:id/setPassword`,
|
|
|
|
verb: 'PATCH'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Self.setPassword = async function(id, newPassword) {
|
2020-09-21 11:24:43 +00:00
|
|
|
await Self.rawSql(`CALL account.user_setPassword(?, ?)`,
|
|
|
|
[id, newPassword]);
|
|
|
|
await Self.app.models.UserAccount.syncById(id, newPassword);
|
2020-03-09 08:00:03 +00:00
|
|
|
};
|
|
|
|
};
|