fix(shard): restrict staff in-game location to admins/moderators #72
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/staff-location-visibility"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The public Staff online list on the Shard page (
/site/shard) exposed each staff member's in-game location (map + coordinates) to everyone — logged-in players and unauthenticated/public visitors alike. This restricts location to privileged viewers, enforced on both the client and the server.Changes
Server —
server/src/router/v1/public/shard.controller.jsgetOnlinenow determines the caller's access level via the existing non-rejectinggetUserFromRequest(req)helper (the same patternsiteModeuses on token-free public routes).map,x,y,z) are included only foradmin/moderatorcallers. For players, editors, and anonymous requests they are omitted from the JSON entirely — not a placeholder — so location can't be read from the network tab.serial+name(online status) are still returned to everyone.Client —
client/src/routes/public/Shard.jsxuseAuth()(user.role), matching howRoleGategates admin-only UI, and only renders the location<span>for admin/moderator viewers. Non-privileged viewers still see who is online, with no location field in the DOM.Docs
/shard/onlineswagger summary and the stale JSX section comment.Tests
New
server/test/publicShardOnline.test.js(5 tests, all green), following the existing controller-unit-test style (stubs the model +getUserFromRequest):Full server suite passes (198 tests); client builds clean.
Note
getUserFromRequestdecodes the session without a per-request DB re-validation (unlikerequireAuth), so a just-demoted admin could still see location until their token expires — consistent with the existingsiteMode"admin preview" trust model, and avoids adding a DB hit to a hot public endpoint. Happy to switch to strict re-validation if preferred.🤖 Generated with Claude Code