feat/multi-device-sessions #79
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/multi-device-sessions"
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?
- Migration 0012 adds user_agent / ip / last_seen_at columns to sessions, indexed on last_seen for the settings query. - New db helpers: create_session_with_origin (UA + IP captured), list_sessions_for_user (live, ordered by last activity), delete_session_for_user (user-scoped so one account cannot revoke another's session), touch_session_last_seen. - Login, register, and the 2FA finalization path now capture the User-Agent header and the client IP from X-Forwarded-For / X-Real-IP when present; auth middleware bumps last_seen_at at most once per minute per session via an in-memory ledger so chat-style request volume does not hammer SQLite. - Settings page renders an Active sessions list with a "{browser} on {os}" label, IP, last-seen, and first-seen timestamps. The current session is badged "This device" and its Revoke button is disabled; logout is the only path to end the current session. - POST /settings/sessions/{id}/revoke deletes the session row, drops the ledger entry, and redirects with session_revoked=1 for the flash. - New db_sessions.rs covers scoping, expiry filtering, last-seen touch, and origin capture; existing test fixtures now run migrations 10/11/12 so legacy create_session calls keep working. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>