diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 875e6affbb5..eb656527d8e 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -314,8 +314,20 @@ class Proposals extends DolibarrApi if (!DolibarrApiAccess::$user->hasRight('propal', 'creer')) { throw new RestException(403, "Insufficiant rights"); } + // Check mandatory fields - $result = $this->_validate($request_data); + $this->_validate($request_data); + + // Check thirdparty validity + $socid = (int) $request_data['socid']; + $thirdpartytmp = new Societe($this->db); + $thirdparty_result = $thirdpartytmp->fetch($socid); + if ($thirdparty_result < 1) { + throw new RestException(404, 'Thirdparty with id='.$socid.' not found or not allowed'); + } + if (!DolibarrApi::_checkAccessToResource('societe', $thirdpartytmp->id)) { + throw new RestException(404, 'Thirdparty with id='.$thirdpartytmp->id.' not found or not allowed'); + } foreach ($request_data as $field => $value) { if ($field === 'caller') {