15 lines
501 B
JavaScript
15 lines
501 B
JavaScript
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 currentUserId = token && token.userId;
|
|
|
|
let worker = await models.Worker.findOne({where: {userFk: currentUserId}});
|
|
ctx.instance.workerFk = worker.id;
|
|
});
|
|
};
|