Skip to content

feat: Account Security & Active Sessions dashboard (#241) - #259

Open
Olumide-01 wants to merge 1 commit into
Lumina-eX:mainfrom
Olumide-01:feat/241-security-dashboard
Open

Olumide-01 wants to merge 1 commit into
Lumina-eX:mainfrom
Olumide-01:feat/241-security-dashboard

Conversation

@Olumide-01

Copy link
Copy Markdown

Summary

Implements the Account Security & Active Sessions dashboard requested in #241. Users can now review account activity, monitor active sessions, and revoke access from a dedicated security page.

Closes #241

What changed

Security dashboard UI — app/dashboard/security/

  • New /dashboard/security page (server wrapper + 'use client' dashboard)
  • Lists active, revoked and expired sessions with device, IP, sign-in time and last-active time
  • Dedicated Login history tab
  • Connected wallet address + network card (address truncated, with copy; network badge + wrong-network warning)
  • Security alerts for suspicious/unfamiliar activity (recent sign-ins from other devices, unfamiliar network, sessions from multiple networks, recent revocations)
  • Confirmation AlertDialog before every revocation; UI only updates after the server confirms
  • Current device is labelled "This device" and offers Sign out instead of revoke
  • Loading skeletons, empty states, error state with retry; responsive across desktop/tablet/mobile
  • Added a Security entry to the dashboard sidebar

API — app/api/auth/sessions/

  • GET /api/auth/sessions — wallet-scoped list + derived alerts
  • POST /api/auth/sessions/[id]/revoke — revokes a session, returns 404/409/400/429/500 with error codes for the UI

Service — lib/auth/sessions.ts, lib/auth/session-types.ts

  • Collapses refresh-token rotation chains (replaced_by_jti) into one logical session per login, so normal token rotation does not appear as revoked sessions
  • Never returns sensitive token material (jti, token_hash)
  • Revocation is scoped by wallet_address (IDOR-safe) and only allowed on active chain tips
  • Pure, client-safe helpers for user-agent parsing and alert heuristics

Data — lib/db/migrations/011_session_history_index.sql adds a (wallet_address, created_at DESC) index for indexed session history.

Tests

pnpm test — added 26 tests covering the service (chain grouping, status derivation, alerts, revocation outcomes), the API routes (auth scoping, sensitive-field non-exposure, error codes) and the UI (render, empty/error states, confirm-then-revoke flow, failed revocation leaves the session active).

Test Files  3 passed (3)
Tests       26 passed (26)

Notes

  • Existing test failures in reviews/deliverables/recommendations and existing tsc strictness errors are pre-existing on main and unrelated to this change (verified on a clean checkout).

- Add /dashboard/security page listing active, revoked and expired sessions
- Add GET /api/auth/sessions and POST /api/auth/sessions/[id]/revoke routes
- Collapse refresh-token rotation chains into logical, wallet-scoped sessions
- Show connected wallet address/network and surface suspicious-activity alerts
- Require confirmation and server confirmation before UI reflects revocation
- Implement loading, empty, error and responsive states
- Add migration index for per-wallet session history and unit/route/UI tests

Closes Lumina-eX#241
@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@Olumide-01 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

[Feature]: Account Security & Active Sessions Page

1 participant