Skip to content

Conversation

@TerrifiedBug
Copy link
Owner

Summary

  • Implements database-tracked sessions with automatic invalidation when password is changed
  • When a user changes their password, all other sessions are logged out while the current session remains active
  • Sessions are now stored in SQLite and verified during token validation

Changes

  • Added sessions table to track active user sessions
  • Create session on login with unique session ID stored in JWT
  • Verify session exists in database during token validation
  • Delete session from database on logout
  • Invalidate all other sessions when password is changed
  • Added clear() method to RateLimiter for test isolation

Test plan

  • Test that logging in creates a session in the database
  • Test that logout deletes the session from the database
  • Test that password change invalidates other sessions but keeps current
  • Test that sessions without valid database records are rejected
  • All 33 auth tests pass

Implements database-tracked sessions with automatic invalidation when
password is changed. This improves security by ensuring that when a user
changes their password, all other sessions are logged out while the
current session remains active.

Changes:
- Add sessions table to track active user sessions in SQLite
- Create session on login with unique session ID stored in JWT
- Verify session exists in database during token validation
- Delete session from database on logout
- Invalidate all other sessions when password is changed
- Add clear() method to RateLimiter for test isolation
- Add tests for session invalidation behavior
@TerrifiedBug TerrifiedBug merged commit 5ac3822 into main Jan 17, 2026
4 checks passed
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.

2 participants