salix/modules/account/back/methods/user-account/sync-by-id.js

32 lines
902 B
JavaScript
Raw Normal View History

2020-09-21 11:24:43 +00:00
module.exports = Self => {
Self.remoteMethod('syncById', {
description: 'Synchronizes the user with the other user databases',
accepts: [
{
arg: 'id',
type: 'number',
description: 'The user id',
required: true
}, {
arg: 'password',
type: 'string',
description: 'The password'
}, {
arg: 'force',
type: 'boolean',
description: 'Whether to force synchronization'
2020-09-21 11:24:43 +00:00
}
],
http: {
path: `/:id/syncById`,
verb: 'PATCH'
}
});
Self.syncById = async function(id, password, force) {
2020-09-21 11:24:43 +00:00
let user = await Self.app.models.Account.findById(id, {fields: ['name']});
await Self.sync(user.name, password, force);
2020-09-21 11:24:43 +00:00
};
};