Handle ticket without old state #384
|
@ -40,15 +40,17 @@ module.exports = Self => {
|
|||
params.workerFk = worker.id;
|
||||
}
|
||||
|
||||
let ticket = await models.TicketState.findById(
|
||||
let ticketState = await models.TicketState.findById(
|
||||
params.ticketFk,
|
||||
{fields: ['stateFk']}
|
||||
);
|
||||
|
||||
let oldStateAllowed = await models.State.isEditable(ctx, ticket.stateFk);
|
||||
let oldStateAllowed;
|
||||
if (ticketState)
|
||||
oldStateAllowed = await models.State.isEditable(ctx, ticketState.stateFk);
|
||||
let newStateAllowed = await models.State.isEditable(ctx, params.stateFk);
|
||||
|
||||
let isAllowed = oldStateAllowed && newStateAllowed;
|
||||
let isAllowed = (!ticketState || oldStateAllowed == true) && newStateAllowed == true;
|
||||
|
||||
if (!isAllowed)
|
||||
throw new UserError(`You don't have enough privileges`, 'ACCESS_DENIED');
|
||||
|
|
|
@ -22928,7 +22928,7 @@
|
|||
},
|
||||
"sha.js": {
|
||||
"version": "2.4.11",
|
||||
"resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",
|
||||
"resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",
|
||||
"integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
|
|
Loading…
Reference in New Issue