salix/services/ticket/common/models/ticketTracking.js

15 lines
444 B
JavaScript
Raw Normal View History

2018-03-21 11:56:18 +00:00
module.exports = function(Self) {
require('../methods/ticketTracking/filter')(Self);
Self.observe('before save', function(ctx, next) {
let token = ctx.options.accessToken;
let userId = token && token.userId;
Self.app.models.Worker.findOne({where: {userFk: userId}}, (err, user) => {
if (err) return next(err);
ctx.instance.workerFk = user.id;
next();
});
});
2018-03-21 11:56:18 +00:00
};