diff --git a/services/nginx/app/routes/usersRoute.php b/services/nginx/app/routes/usersRoute.php index ed84f274..7311a0d8 100644 --- a/services/nginx/app/routes/usersRoute.php +++ b/services/nginx/app/routes/usersRoute.php @@ -242,7 +242,7 @@ class usersRoute $enabled = strtolower((string)($this->fromQuery('include_limited_backoffice_employees') ?? 'false')) === 'true'; $filters = $this->fromQuery('filters'); - if (!$enabled || $filters === null || $filters === '') { + if ($filters === null || $filters === '') { return [ 'enabled' => false, 'filters' => null, @@ -259,14 +259,23 @@ class usersRoute if (!$isEmployeeFilter) { return [ 'enabled' => false, - 'filters' => $filters, + 'filters' => null, 'additional_where' => null, ]; } - unset($filterArray['customer_number']); $activeLimitedEmployeeSubquery = 'SELECT `user_id` FROM `limited_backoffice_employees` WHERE `deactivated_at` IS NULL'; + if (!$enabled) { + return [ + 'enabled' => false, + 'filters' => null, + 'additional_where' => '`id` NOT IN (' . $activeLimitedEmployeeSubquery . ')', + ]; + } + + unset($filterArray['customer_number']); + return [ 'enabled' => true, 'filters' => $filterArray === [] ? 'id:NOT ZERO' : $users->array_to_filters($filterArray), diff --git a/services/nginx/app/tests/Api/LimitedBackofficeApiTest.php b/services/nginx/app/tests/Api/LimitedBackofficeApiTest.php index d53bcda4..f42ed88e 100644 --- a/services/nginx/app/tests/Api/LimitedBackofficeApiTest.php +++ b/services/nginx/app/tests/Api/LimitedBackofficeApiTest.php @@ -897,8 +897,6 @@ it('creates updates lists and deactivates scoped employees without exposing raw 'edit_order_items', 'delete_order_items', 'list_order_attachments', - 'add_order_attachments', - 'download_order_attachments', 'list_products', 'list_categories', 'list_department_categories',