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:
minimexat 2026-07-13 14:29:21 +02:00 committed by GitHub
parent 9e709619d9
commit 0442259154
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);
}