From 0fc2de2155af31bc49925365f82a4e9447209353 Mon Sep 17 00:00:00 2001 From: Cris Date: Wed, 30 Oct 2019 15:05:31 +0100 Subject: [PATCH] Fixed & Secured: Approving LA not causing permission error anymore Before the organisational unit of the lv was sent via AJAX to the server and used for checking the permissions on that organisational unit. This was insecure (post data manipulation) and organisational units were wrong (prepared string instead of oe_kurzbz). This is fixed now by serverside check of organisational unit. (based on given vertrag_id) --- .../lehre/lehrauftrag/LehrauftragErteilen.php | 28 +++++++++++++++++-- .../lehre/lehrauftrag/approveLehrauftrag.php | 3 +- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/application/controllers/lehre/lehrauftrag/LehrauftragErteilen.php b/application/controllers/lehre/lehrauftrag/LehrauftragErteilen.php index 83d2e4b81..2f6f60f43 100644 --- a/application/controllers/lehre/lehrauftrag/LehrauftragErteilen.php +++ b/application/controllers/lehre/lehrauftrag/LehrauftragErteilen.php @@ -128,13 +128,37 @@ class LehrauftragErteilen extends Auth_Controller { $mitarbeiter_uid = (isset($lehrauftrag->mitarbeiter_uid)) ? $lehrauftrag->mitarbeiter_uid : null; $vertrag_id = (isset($lehrauftrag->vertrag_id)) ? $lehrauftrag->vertrag_id : null; - $lv_oe_kurzbz = (isset($lehrauftrag->lv_oe_kurzbz)) ? $lehrauftrag->lv_oe_kurzbz : null; - // Check if user is entitled to approve this Lehrauftrag + $lv_oe_kurzbz = null; + + // Retrieve organisational unit to which the lehrveranstaltung of the contract belongs to + // * first get lehrveranstaltung + $result = $this->VertragModel->getLehreinheitData($vertrag_id, 'lehrveranstaltung_id'); + if (hasData($result)) + { + // * then get corresponding organisational unit + $this->load->model('education/Lehrveranstaltung_model', 'Lehrveranstaltung_model'); + $result = $this->LehrveranstaltungModel->load($result->retval[0]->lehrveranstaltung_id); + if (hasData($result)) + { + $lv_oe_kurzbz = $result->retval[0]->oe_kurzbz; + } + elseif (isError(($result))) + { + show_error($result->retval); + } + } + elseif (isError($result)) + { + show_error($result->retval); + } + + // Check if user is entitled to approve this lehrauftrag (by permission and organisational unit) if (!$this->permissionlib->isBerechtigt(self::BERECHTIGUNG_LEHRAUFTRAG_ERTEILEN, 'suid', $lv_oe_kurzbz)){ show_error('Keine Erteilberechtigung für diese Organisationseinheit: '. $lv_oe_kurzbz); } + // Approve lehrauftrag by setting vertragsstatus to 'erteilt' $result = $this->VertragvertragsstatusModel->setStatus($vertrag_id, $mitarbeiter_uid, 'erteilt'); if ($result->retval) { diff --git a/application/views/lehre/lehrauftrag/approveLehrauftrag.php b/application/views/lehre/lehrauftrag/approveLehrauftrag.php index 6e8c38e29..156c379c0 100644 --- a/application/views/lehre/lehrauftrag/approveLehrauftrag.php +++ b/application/views/lehre/lehrauftrag/approveLehrauftrag.php @@ -681,8 +681,7 @@ $(function() { return { 'row_index': data.row_index, 'mitarbeiter_uid' : data.mitarbeiter_uid, - 'vertrag_id' : data.vertrag_id, - 'lv_oe_kurzbz' : data.lv_oe_kurzbz + 'vertrag_id' : data.vertrag_id } });