Bug #306 Modificar TicketTracking para tener en cuenta los nuevos ACL
This commit is contained in:
parent
e6b7cd8516
commit
0fdb4a4785
|
@ -153,7 +153,8 @@
|
||||||
"menu": {
|
"menu": {
|
||||||
"description": "Tracking",
|
"description": "Tracking",
|
||||||
"icon": "remove_red_eye"
|
"icon": "remove_red_eye"
|
||||||
}
|
},
|
||||||
|
"acl": ["production"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "/edit",
|
"url": "/edit",
|
||||||
|
|
|
@ -8,14 +8,6 @@ module.exports = function(Self) {
|
||||||
let token = ctx.options.accessToken;
|
let token = ctx.options.accessToken;
|
||||||
let userId = token && token.userId;
|
let userId = token && token.userId;
|
||||||
|
|
||||||
let isEmployee = await models.Account.hasRole(userId, 'employee');
|
|
||||||
let isProduction = await models.Account.hasRole(userId, 'production');
|
|
||||||
let isAlertLevelZero = await models.State.isAlertLevelZero(ctx.instance.stateFk);
|
|
||||||
let ticketAlertLevel = await models.TicketState.findOne({where: {id: ctx.instance.ticketFk}, fields: ["alertLevel"]});
|
|
||||||
|
|
||||||
if ((!isProduction && !isAlertLevelZero) || !isEmployee || (isEmployee && ticketAlertLevel != 0 && !isProduction))
|
|
||||||
throw new Error("You don't have enough privileges to do that");
|
|
||||||
|
|
||||||
let user = await models.Worker.findOne({where: {userFk: userId}});
|
let user = await models.Worker.findOne({where: {userFk: userId}});
|
||||||
ctx.instance.workerFk = user.id;
|
ctx.instance.workerFk = user.id;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue