fix: prevent deleting absences for past dates #3346

Merged
jorgep merged 9 commits from hotfix-restrictAbsencePrivs into master 2025-01-09 08:53:25 +00:00
2 changed files with 8 additions and 0 deletions
Showing only changes of commit c07e30a89c - Show all commits

View File

@ -0,0 +1,2 @@
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
VALUES ('Worker','canDeleteAbsenceInPast','WRITE','ALLOW','ROLE','hr');

View File

@ -53,6 +53,12 @@ module.exports = Self => {
}
}
}, myOptions);
const canDeleteAbsenceInPast =
await models.ACL.checkAccessAcl(ctx, 'Worker', 'canDeleteAbsenceInPast', 'WRITE');
jorgep marked this conversation as resolved Outdated
Outdated
Review

En create ya esta codigo parecido b14268ef1b/modules/worker/back/methods/worker/createAbsence.js (L63)

Ver si unificar

En create ya esta codigo parecido https://gitea.verdnatura.es/verdnatura/salix/src/commit/b14268ef1bfd0091526255e390255ad664f3839a/modules/worker/back/methods/worker/createAbsence.js#L63 Ver si unificar
if (!canDeleteAbsenceInPast && Date.vnNow() > absence.dated.getTime())
throw new UserError(`Holidays to past days not available`);
const result = await absence.destroy(myOptions);
const labour = absence.labour();
const department = labour && labour.department();