A free open source IT asset/license management system
API: Fixed API to let superusers see across companies for users and assets
snipe4966cecea449
diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.phpindex 68a9666a9f..63446092f5 100644--- a/app/Http/Controllers/Api/AssetsController.php+++ b/app/Http/Controllers/Api/AssetsController.php@@ -617,7 +617,13 @@ class AssetsController extends Controller$assets = Company::scopeCompanyables($assets);// Allow further narrowing to a specific company passed via data-company-id on the select.- if ((Setting::getSettings()->full_multiple_companies_support == '1') && $request->filled('companyId')) {+ // Superusers MUST bypass this filter — they manage across companies and need to see every+ // asset on checkout dropdowns. Scoping superusers to the item's company breaks the umbrella-+ // corp / service-provider workflow where one admin checks items out across sub-companies.+ // See: https://github.com/snipe/snipe-it/issues/ (v8.6.3 regression report)+ if ((Setting::getSettings()->full_multiple_companies_support == '1')+ && $request->filled('companyId')+ && ! auth()->user()->isSuperUser()) {$companyIds = array_values(array_filter(array_map('intval', explode(',', $request->input('companyId')))));if (! empty($companyIds)) {$assets->whereIn('assets.company_id', $companyIds);diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.phpindex 1fb15285b2..a2395beda6 100644--- a/app/Http/Controllers/Api/UsersController.php+++ b/app/Http/Controllers/Api/UsersController.php@@ -401,7 +401,13 @@ class UsersController extends Controller$users = Company::scopeCompanyables($users, 'company_id', 'users');// Allow further narrowing to a specific company passed via data-company-ids on the select.- if ((Setting::getSettings()->full_multiple_companies_support == '1') && $request->filled('companyId')) {+ // Superusers MUST bypass this filter — they manage across companies and need to see every+ // user on checkout dropdowns. Scoping superusers to the item's company breaks the umbrella-+ // corp / service-provider workflow where one admin checks items out to users in any sub-company.+ // See: https://github.com/snipe/snipe-it/issues/ (v8.6.3 regression report)+ if ((Setting::getSettings()->full_multiple_companies_support == '1')+ && $request->filled('companyId')+ && ! auth()->user()->isSuperUser()) {$companyIds = array_values(array_filter(array_map('intval', explode(',', $request->input('companyId')))));if (! empty($companyIds)) {$users = Company::scopeUsersByCompanyIds($users, $companyIds);