salix/modules/ticket/back/models/ticket-request.js

18 lines
643 B
JavaScript
Raw Normal View History

2018-11-13 10:26:36 +00:00
const LoopBackContext = require('loopback-context');
module.exports = function(Self) {
2019-04-05 13:20:12 +00:00
require('../methods/ticket-request/filter')(Self);
require('../methods/ticket-request/deny')(Self);
require('../methods/ticket-request/confirm')(Self);
2018-11-13 10:26:36 +00:00
Self.observe('before save', async function(ctx) {
if (ctx.isNewInstance) {
const loopBackContext = LoopBackContext.getCurrentContext();
let filter = {where: {userFk: loopBackContext.active.accessToken.userId}};
let worker = await Self.app.models.Worker.findOne(filter);
ctx.instance.requesterFk = worker.id;
}
});
};