Require booking add node for subuser booking creation
This commit is contained in:
@@ -87,7 +87,8 @@ class orderBookingRoute
|
||||
$response->success($order_bookings_o->asArray());
|
||||
},
|
||||
[
|
||||
'add_bookings' => 'Permission to create order bookings for another customer or department scope.'
|
||||
'add_bookings' => 'Permission to create order bookings for another customer or department scope.',
|
||||
'add_own_bookings' => 'Permission to create own order bookings. Subusers require node: BOOKINGS_ADD.'
|
||||
]
|
||||
);
|
||||
|
||||
@@ -651,7 +652,21 @@ class orderBookingRoute
|
||||
|
||||
private function requireOrderBookingCreateAccess(int $targetCustomerNumber, int $departmentId): void
|
||||
{
|
||||
if ($this->isOrderBookingCustomerSession() && $this->isOwnCustomerContext($targetCustomerNumber)) {
|
||||
$auth = new authentication();
|
||||
|
||||
if ($auth->get_subuser() !== false && $this->isOwnCustomerContext($targetCustomerNumber)) {
|
||||
$permissionOwn = self::definePermission('add_own_bookings', subusers_permission_node_key::BOOKINGS_ADD);
|
||||
if (!self::hasPermission($permissionOwn)) {
|
||||
$this->emitForbidden([$permissionOwn]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
$auth->get_user() !== false
|
||||
&& self::hasPermission('user')
|
||||
&& $this->isOwnCustomerContext($targetCustomerNumber)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user