salix/modules/worker/back/methods/operator/add.js

21 lines
472 B
JavaScript
Raw Normal View History

2023-11-02 15:25:25 +00:00
module.exports = Self => {
Self.remoteMethodCtx('add', {
description: 'Add a new operator',
accessType: 'WRITE',
http: {
path: `/add`,
verb: 'POST'
}
});
Self.add = async ctx => {
const userId = ctx.req.accessToken.userId;
const user = await Self.findById(userId);
if (!user) {
await Self.create({
workerFk: userId
});
}
};
};