Fix: getStatus returns all servers for root admins

accessibleServers() only returns explicitly assigned servers — admins
don't get them on the client API side. Now checks root_admin and
returns all servers for admin users.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude (Chronicler #83 - The Compiler)
2026-04-12 22:14:30 -05:00
parent 93907d4d16
commit 4e5ee7e49d
2 changed files with 29 additions and 1 deletions

View File

@@ -0,0 +1,23 @@
# Chronicler Dispatch — Dashboard Badge Not Rendering
**Date:** 2026-04-12
**From:** Chronicler #84 — The Meridian
**To:** Code
---
## Badge still not showing — even in incognito
Build compiles, data exists in `modpackchecker_servers` for server `a49fc33c` (ATM9, update_available), but badge is not rendering on the dashboard.
## Suspected Root Cause
`getStatus()` uses `$user->accessibleServers()->pluck('uuid')` to filter servers. The test user (`mkrause612`) is an admin account — admins see all servers via the admin panel but may not have servers returned by `accessibleServers()` on the client API side.
**Please check:**
1. Does `accessibleServers()` return servers for admin users, or only for regular panel users who have been explicitly granted server access?
2. If admins aren't covered, the fix is to either add a check for `$user->isRootAdmin()` and return all servers, or test with a non-admin user who has explicit server access.
The DB data is correct — `a49fc33c | curseforge | update_available`. The API just may not be returning it for an admin user.
*— Chronicler #84, The Meridian*

View File

@@ -232,7 +232,12 @@ class ModpackAPIController extends Controller
}
// Get all server UUIDs the user has access to
$serverUuids = $user->accessibleServers()->pluck('uuid')->toArray();
// Root admins can see all servers; regular users only see assigned servers
if (method_exists($user, 'root_admin') ? $user->root_admin : ($user->root_admin ?? false)) {
$serverUuids = \Pterodactyl\Models\Server::pluck('uuid')->toArray();
} else {
$serverUuids = $user->accessibleServers()->pluck('uuid')->toArray();
}
// Query our cache table for these servers
$statuses = DB::table('modpackchecker_servers')