2023-09-25 06:33:16 +00:00
|
|
|
module.exports = Self => {
|
|
|
|
Self.remoteMethodCtx('updateUser', {
|
|
|
|
description: 'Update user data',
|
|
|
|
accepts: [
|
|
|
|
{
|
|
|
|
arg: 'id',
|
|
|
|
type: 'integer',
|
|
|
|
description: 'The user id',
|
|
|
|
required: true,
|
|
|
|
http: {source: 'path'}
|
|
|
|
}, {
|
|
|
|
arg: 'name',
|
|
|
|
type: 'string',
|
|
|
|
description: 'The user name',
|
|
|
|
}, {
|
|
|
|
arg: 'nickname',
|
|
|
|
type: 'string',
|
|
|
|
description: 'The user nickname',
|
|
|
|
}, {
|
|
|
|
arg: 'email',
|
|
|
|
type: 'string',
|
|
|
|
description: 'The user email'
|
|
|
|
}, {
|
|
|
|
arg: 'lang',
|
|
|
|
type: 'string',
|
|
|
|
description: 'The user lang'
|
2024-08-13 10:30:37 +00:00
|
|
|
}, {
|
|
|
|
arg: 'twoFactor',
|
|
|
|
type: 'string',
|
|
|
|
description: 'The user twoFactor'
|
2023-09-25 06:33:16 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
http: {
|
|
|
|
path: `/:id/update-user`,
|
|
|
|
verb: 'PATCH'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2024-08-13 10:30:37 +00:00
|
|
|
Self.updateUser = async(ctx, id, name, nickname, email, lang, twoFactor) => {
|
2023-09-25 06:33:16 +00:00
|
|
|
await Self.userSecurity(ctx, id);
|
2024-08-13 10:30:37 +00:00
|
|
|
await Self.upsertWithWhere({id}, {name, nickname, email, lang, twoFactor});
|
2023-09-25 06:33:16 +00:00
|
|
|
};
|
|
|
|
};
|