Handle ticket without old state
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
7464609157
commit
89667a18c9
|
@ -40,15 +40,17 @@ module.exports = Self => {
|
||||||
params.workerFk = worker.id;
|
params.workerFk = worker.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
let ticket = await models.TicketState.findById(
|
let ticketState = await models.TicketState.findById(
|
||||||
params.ticketFk,
|
params.ticketFk,
|
||||||
{fields: ['stateFk']}
|
{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 newStateAllowed = await models.State.isEditable(ctx, params.stateFk);
|
||||||
|
|
||||||
let isAllowed = oldStateAllowed && newStateAllowed;
|
let isAllowed = (!ticketState || oldStateAllowed == true) && newStateAllowed == true;
|
||||||
|
|
||||||
if (!isAllowed)
|
if (!isAllowed)
|
||||||
throw new UserError(`You don't have enough privileges`, 'ACCESS_DENIED');
|
throw new UserError(`You don't have enough privileges`, 'ACCESS_DENIED');
|
||||||
|
|
|
@ -22928,7 +22928,7 @@
|
||||||
},
|
},
|
||||||
"sha.js": {
|
"sha.js": {
|
||||||
"version": "2.4.11",
|
"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==",
|
"integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
|
|
Loading…
Reference in New Issue