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'
|
2020-11-12 22:20:25 +00:00
|
|
|
}, {
|
|
|
|
arg: 'force',
|
|
|
|
type: 'boolean',
|
|
|
|
description: 'Whether to force synchronization'
|
2020-09-21 11:24:43 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
http: {
|
|
|
|
path: `/:id/syncById`,
|
|
|
|
verb: 'PATCH'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-11-12 22:20:25 +00:00
|
|
|
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']});
|
2020-11-12 22:20:25 +00:00
|
|
|
await Self.sync(user.name, password, force);
|
2020-09-21 11:24:43 +00:00
|
|
|
};
|
|
|
|
};
|