Bug #306 Modificar TicketTracking para tener en cuenta los nuevos ACL

This commit is contained in:
gerard 2018-05-16 12:56:46 +02:00
parent e6b7cd8516
commit 0fdb4a4785
2 changed files with 2 additions and 9 deletions

View File

@ -153,7 +153,8 @@
"menu": {
"description": "Tracking",
"icon": "remove_red_eye"
}
},
"acl": ["production"]
},
{
"url": "/edit",

View File

@ -8,14 +8,6 @@ module.exports = function(Self) {
let token = ctx.options.accessToken;
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}});
ctx.instance.workerFk = user.id;
});