2018-03-21 11:56:18 +00:00
|
|
|
module.exports = function(Self) {
|
|
|
|
require('../methods/ticketTracking/filter')(Self);
|
2018-03-27 12:24:47 +00:00
|
|
|
|
|
|
|
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
|
|
|
};
|