Add admin foundation + Users resource (Filament replacement, slice 1)

Plain App Router admin (aligned to habbo-next, no Refine):
- rank surfaced on the NextAuth session; staff guard isStaff() [pure,
  unit-tested] + requireStaff() reading min_staff_rank, gating /admin.
- /admin dashboard (counts), /admin/users (paginated + search),
  /admin/users/[id] detail.
- src/actions/admin-users.ts: staff-gated server actions wiring the user editor
  to the existing services — giveCurrency (RCON or DB fallback), setMotto/setRank
  (DB + RCON), alertUser, disconnectUser.

Verified: tsc exit 0, vitest 45/45, next build exit 0 (/admin routes).
This commit is contained in:
Simo committed 2026-06-27 16:51:47 +02:00
1 parent d9a8ce532f
commit 9f81096f05
10 files changed
+334 -3

No files matched your search

+7 -2
View File
@@ -35,14 +35,19 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
});
}
return { id: String(user.id), name: user.username };
return { id: String(user.id), name: user.username, rank: user.rank };
},
}),
],
callbacks: {
// NextAuth stores the user id in token.sub automatically; surface it on the session.
jwt({ token, user }) {
if (user) token.rank = (user as { rank?: number }).rank;
return token;
},
// NextAuth stores the user id in token.sub automatically; surface id + rank.
session({ session, token }) {
if (token.sub && session.user) session.user.id = token.sub;
if (typeof token.rank === "number" && session.user) session.user.rank = token.rank;
return session;
},
},