diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 9e33ca357d3..ad0c3dd7b17 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -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); }