42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
|
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'
|
||
|
}
|
||
|
],
|
||
|
http: {
|
||
|
path: `/:id/update-user`,
|
||
|
verb: 'PATCH'
|
||
|
}
|
||
|
});
|
||
|
|
||
|
Self.updateUser = async(ctx, id) => {
|
||
|
await Self.userSecurity(ctx, id);
|
||
|
const user = await Self.app.models.VnUser.findById(id,
|
||
|
{fields: ['id', 'name', 'nickname', 'email', 'lang', 'password']});
|
||
|
await user.updateAttributes(ctx.args);
|
||
|
};
|
||
|
};
|