diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index c07e382f3da..5c446a0aadc 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -450,6 +450,19 @@ class Tickets extends DolibarrApi throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } + // Check thirdparty validity + $socid = (int) $request_data['socid']; + if ($socid > 0) { + $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') { // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again with the caller