mc-dashboard/lib
hurkicorgi 1ac5513d2c Role-based access: admin vs superadmin
- Credentials provider now resolves two distinct accounts from env:
    SUPERADMIN_USERNAME / SUPERADMIN_PASSWORD → role "superadmin"
    ADMIN_USERNAME      / ADMIN_PASSWORD      → role "admin"
  The role is carried through the JWT and Session callbacks so the UI
  and API can gate on it. Types extended via types/next-auth.d.ts.
- lib/auth.ts exports requireRole(minRole) and sessionRole(session).
- /api/players POST rejects "op" and "deop" with 403 unless the caller
  is superadmin. All other player actions (whitelist add/remove, ban,
  pardon) remain available to both roles.
- lib/use-role.ts (client hook) exposes role / isSuperadmin / authed
  for UI gating without duplicating session typing.
- PlayerManager: Add-OP button and per-row Deop action are hidden or
  disabled for non-superadmin; when a regular admin is viewing the
  Ops tab, a banner explains the read-only state.
- PlayerDrawer: Make Op / Deop button disabled with tooltip for
  non-superadmin; whitelist, ban, pardon unchanged.
- Navbar: subtle role pill next to the user name ("Super" for
  superadmin amber-tinted, "Admin" for admin).
- Migration note: the existing ADMIN_* credentials now log in as the
  restricted admin role. Set SUPERADMIN_USERNAME + SUPERADMIN_PASSWORD
  in .env.local to retain operator-management ability. A placeholder
  superadmin account was generated in .env.local; the password is in
  the commit terminal output only, not the repo.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 06:52:05 -06:00
..
auth.ts Role-based access: admin vs superadmin 2026-04-13 06:52:05 -06:00
cache.ts Performance: RCON pooling, route caching, parallel status probe 2026-04-13 00:59:10 -06:00
chat-log.ts SSE events bridge, PWA service worker, offline banner, lazy admin tabs 2026-04-13 05:48:00 -06:00
constants.ts Initial commit: Minecraft dashboard 2026-04-13 00:46:58 -06:00
events.ts Pass 3 next slice: snapshot polish, analytics depth, player drawer 2026-04-13 05:39:32 -06:00
modrinth.ts Pass 3 first slice: mod update action, error boundaries, a11y, palette 2026-04-13 05:30:23 -06:00
mods.ts UX/UI/perf pass: admin tabs, theme toggle, log polish, mod search, JAR cache 2026-04-13 04:58:25 -06:00
player-stats.ts Rich per-player stats + pick-your-metric leaderboard 2026-04-13 06:37:50 -06:00
rcon.ts Performance: RCON pooling, route caching, parallel status probe 2026-04-13 00:59:10 -06:00
server-status.ts SSE events bridge, PWA service worker, offline banner, lazy admin tabs 2026-04-13 05:48:00 -06:00
snapshots.ts Pass 3 next slice: snapshot polish, analytics depth, player drawer 2026-04-13 05:39:32 -06:00
time.ts Per-player playtime tracking + sparkline hover tooltips 2026-04-13 06:24:13 -06:00
use-role.ts Role-based access: admin vs superadmin 2026-04-13 06:52:05 -06:00
utils.ts Initial commit: Minecraft dashboard 2026-04-13 00:46:58 -06:00