Fix add / delete contact access

This commit is contained in:
ptibogxiv 2019-06-16 14:18:26 +02:00 committed by GitHub
parent 6760368b64
commit 651f4158ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -415,21 +415,16 @@ class Orders extends DolibarrApi
*/
public function postContact($id, $contactid, $type)
{
if(!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
if(!$result) {
throw new RestException(404, 'Order not found');
if (! DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
if (!in_array($type, array('BILLING', 'SHIPPING', 'CUSTOMER'), true)) {
throw new RestException(500, 'Availables types: BILLING, SHIPPING OR CUSTOMER');
$result = $this->commande->fetch($id);
if (! $result) {
throw new RestException(404, 'Order not found');
}
if(!DolibarrApi::_checkAccessToResource('order', $this->commande->id)) {
if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@ -457,17 +452,16 @@ class Orders extends DolibarrApi
*/
public function deleteContact($id, $rowid)
{
if(!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
if(!$result) {
throw new RestException(404, 'Order not found');
if (! DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
if(!DolibarrApi::_checkAccessToResource('order', $this->commande->id)) {
$result = $this->commande->fetch($id);
if (! $result) {
throw new RestException(404, 'Order not found');
}
if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}