FIX: restrict establishment setup API to admin users (#39137)
* FIX: Restrict establishment setup API to admins * Update ChangeLog --------- Co-authored-by: f-hoedl <hoefla14@htl-kaindorf.ac.at> Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
parent
9e709619d9
commit
0442259154
1 changed files with 10 additions and 0 deletions
|
|
@ -2744,6 +2744,9 @@ class Setup extends DolibarrApi
|
|||
public function getEstablishments()
|
||||
{
|
||||
$list = array();
|
||||
if (!DolibarrApiAccess::$user->admin) {
|
||||
throw new RestException(403, 'Error API open to admin users only');
|
||||
}
|
||||
|
||||
$limit = 0;
|
||||
|
||||
|
|
@ -2782,6 +2785,10 @@ class Setup extends DolibarrApi
|
|||
*/
|
||||
public function getEtablishmentByID($id)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->admin) {
|
||||
throw new RestException(403, 'Error API open to admin users only');
|
||||
}
|
||||
|
||||
$establishment = new Establishment($this->db);
|
||||
|
||||
$result = $establishment->fetch($id);
|
||||
|
|
@ -2790,6 +2797,9 @@ class Setup extends DolibarrApi
|
|||
} elseif ($result == 0) {
|
||||
throw new RestException(404, 'Establishment not found');
|
||||
}
|
||||
if (!in_array($establishment->entity, explode(',', getEntity('establishment')))) {
|
||||
throw new RestException(404, 'Establishment not found');
|
||||
}
|
||||
|
||||
return $this->_cleanObjectDatas($establishment);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue