module.exports = function(Self) { require('../methods/ticket-tracking/changeState')(Self); Self.validatesPresenceOf('stateFk', {message: 'State cannot be blank'}); Self.observe('before save', async function(ctx) { let models = Self.app.models; let token = ctx.options.accessToken; let userId = token && token.userId; let user = await models.Worker.findOne({where: {userFk: userId}}); ctx.instance.workerFk = user.id; }); };