Fix add / delete contact access
This commit is contained in:
parent
6760368b64
commit
651f4158ac
@ -415,21 +415,16 @@ class Orders extends DolibarrApi
|
|||||||
*/
|
*/
|
||||||
public function postContact($id, $contactid, $type)
|
public function postContact($id, $contactid, $type)
|
||||||
{
|
{
|
||||||
if(!DolibarrApiAccess::$user->rights->commande->creer) {
|
if (! DolibarrApiAccess::$user->rights->commande->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
|
||||||
|
|
||||||
$result = $this->commande->fetch($id);
|
|
||||||
|
|
||||||
if(!$result) {
|
|
||||||
throw new RestException(404, 'Order not found');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array($type, array('BILLING', 'SHIPPING', 'CUSTOMER'), true)) {
|
$result = $this->commande->fetch($id);
|
||||||
throw new RestException(500, 'Availables types: BILLING, SHIPPING OR CUSTOMER');
|
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);
|
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)
|
public function deleteContact($id, $rowid)
|
||||||
{
|
{
|
||||||
if(!DolibarrApiAccess::$user->rights->commande->creer) {
|
if (! DolibarrApiAccess::$user->rights->commande->creer) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
|
||||||
|
|
||||||
$result = $this->commande->fetch($id);
|
|
||||||
|
|
||||||
if(!$result) {
|
|
||||||
throw new RestException(404, 'Order not found');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user