15 lines
444 B
JavaScript
15 lines
444 B
JavaScript
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();
|
|
});
|
|
});
|
|
};
|