diff --git a/db/versions/11372-azureMedeola/00-firstScript.sql b/db/versions/11372-azureMedeola/00-firstScript.sql index b98701509..53295e9f8 100644 --- a/db/versions/11372-azureMedeola/00-firstScript.sql +++ b/db/versions/11372-azureMedeola/00-firstScript.sql @@ -1,2 +1,2 @@ INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) - VALUES ('Worker','isHr','WRITE','ALLOW','ROLE','hr'); + VALUES ('Worker','canCreateAbsenceInPast','WRITE','ALLOW','ROLE','hr'); diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index 264de4dd3..dad02d0dc 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -54,7 +54,7 @@ module.exports = Self => { try { const isSubordinate = await models.Worker.isSubordinate(ctx, id, myOptions); const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE'); - const isHr = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isHr', 'WRITE'); + const canCreateAbsenceInPast = await models.ACL.checkAccessAcl(ctx, 'Worker', 'canCreateAbsenceInPast', 'WRITE'); if (!isSubordinate || (isSubordinate && userId == id && !isTeamBoss)) throw new UserError(`You don't have enough privileges`); @@ -116,7 +116,7 @@ module.exports = Self => { const newDate = new Date(ctx.args.dated).getTime(); const nowDate = now.getTime(); - if ((nowDate > newDate) && !isHr) + if ((nowDate > newDate) && !canCreateAbsenceInPast) throw new UserError(`Holidays to past days not available`); const absence = await models.Calendar.create({