Files
lucioandClaude Opus 4.8 67731cfcac Persist sessions in SQLite so logins survive a server restart
Sessions were stored in an in-memory map, so every server reboot logged the
admin out. Back the session store with the database instead:

- Add a sessions table (token, expires_at, created_at) created via the existing
  migrate() (CREATE TABLE IF NOT EXISTS), backwards-compatible with deployed DBs.
- Add CreateSession / SessionValid / DeleteSession / CleanupSessions; expiry is
  checked in SQL against datetime('now') (UTC).
- sessionStore is now a thin DB-backed wrapper with the same Create/Valid/Delete
  interface; the hourly cleanup goroutine purges expired rows (plus once at
  startup). Login, logout, requireAuth, and isLoggedIn are unchanged.

The session cookie was already persistent (MaxAge), so logins now survive both
browser and server restarts until session_hours expiry.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-05 01:08:25 -07:00
..