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)
This commit is contained in:
Cris
2019-10-30 15:05:31 +01:00
committed by hainberg
parent 47f1fe1377
commit 0fc2de2155
2 changed files with 27 additions and 4 deletions
@@ -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) {
@@ -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
}
});