Skip to content

feat: add authenticated session handling for admin actions#53

Open
Anichris-koded wants to merge 2 commits into
Adamantine-guild:mainfrom
Anichris-koded:feat/admin-session-handling-37
Open

feat: add authenticated session handling for admin actions#53
Anichris-koded wants to merge 2 commits into
Adamantine-guild:mainfrom
Anichris-koded:feat/admin-session-handling-37

Conversation

@Anichris-koded

Copy link
Copy Markdown

Summary

Implements issue #37 — adds a clear authenticated-session boundary for admin actions.

Changes

  • AdminSessionStatus type — new disconnected | connected | authenticating | authenticated | expired union in lib/api/types.ts
  • SiweAuthContext — exposes sessionStatus and markExpired(); derived from local state, no extra API calls
  • AdminGuard — branches on sessionStatus; new ExpiredSessionPrompt for the expired state
  • ConnectButton — yellow "Session Expired" badge + "Re-authenticate" when sessionStatus === 'expired'
  • Admin mutation error handlers — call markExpired() on 401, rolling back optimistically and surfacing the inline re-auth banner
  • AuthError export — re-exported from lib/api/live.ts as alias of ApiError
  • Mock simulationNEXT_PUBLIC_MOCK_SESSION_STATE=expired|unauthenticated for local testing without a backend
  • Docsdocs/admin-session-contract.md with backend endpoint contract, field shapes, and local dev flags
  • Bug fix — missing cn import in api-states.tsx; duplicate imports and broken FeatureGate in policies page

Tested

  • npm run typecheck exits 0

Acceptance criteria

  • Admin guard distinguishes connected wallet from authenticated admin session
  • Expired or missing sessions block privileged admin actions
  • Mock mode can simulate authenticated and unauthenticated admin states
  • Live API calls include auth headers through a safe boundary
  • Documentation describes the expected backend session contract

Closes #37

…e-guild#37)

- Add AdminSessionStatus type (disconnected/connected/authenticating/authenticated/expired)
- Expose sessionStatus and markExpired() from SiweAuthContext
- AdminGuard branches on sessionStatus; new ExpiredSessionPrompt for expired state
- ConnectButton shows session-expired badge with re-authenticate action
- Admin mutation onError handlers call markExpired() on 401
- Export AuthError alias from lib/api/live.ts
- Mock API: NEXT_PUBLIC_MOCK_SESSION_STATE=expired|unauthenticated for local simulation
- Fix pre-existing missing cn import in components/ui/api-states.tsx
- Fix duplicate imports and broken FeatureGate nesting in policies page
- Add docs/admin-session-contract.md with backend endpoint contract
@Anichris-koded Anichris-koded deleted the feat/admin-session-handling-37 branch June 25, 2026 17:16
@Anichris-koded Anichris-koded restored the feat/admin-session-handling-37 branch June 25, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add authenticated session handling for admin actions

1 participant