Skip to content

fix: clean up expired sessions in SessionMiddleware#7

Merged
tompscanlan merged 3 commits intoOpenMeet-Team:mainfrom
majiayu000:main
Jan 4, 2026
Merged

fix: clean up expired sessions in SessionMiddleware#7
tompscanlan merged 3 commits intoOpenMeet-Team:mainfrom
majiayu000:main

Conversation

@majiayu000
Copy link
Contributor

Summary

  • Delete expired sessions from database when detected in SessionMiddleware
  • Add test to verify expired sessions are properly cleaned up

Changes

  • internal/oauth/middleware.go: Call storage.DeleteSession() when session is expired
  • internal/oauth/middleware_test.go: Add verification that expired session is deleted from database

Test plan

  • All unit tests pass (go test ./...)
  • E2E tests pass (go test -tags=e2e ./internal/oauth/...)
  • Verified expired session is deleted after middleware call

Fixes #3

🤖 Generated with Claude Code

majiayu000 and others added 2 commits January 4, 2026 11:13
Previously, expired sessions were detected but not removed from the
database, causing them to accumulate indefinitely. Now when an expired
session is encountered, it is deleted from the database before
continuing with the request.

Fixes OpenMeet-Team#3

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Contributor

@tompscanlan tompscanlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we detect an expired session, we delete it from the DB but don't clear the session cookie on the browser. The user will keep sending the stale cookie until it naturally expires.

Not blocking, just curious if you considered adding something like:

c.SetCookie(&http.Cookie{Name: "session", MaxAge: -1})

Address reviewer feedback: when detecting an expired session, now also
clear the browser cookie by setting MaxAge=-1. This prevents the client
from sending stale session cookies on subsequent requests.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@majiayu000
Copy link
Contributor Author

Thanks for the feedback! Good catch - I've added the cookie clearing logic in commit 6bbf439.

Now when an expired session is detected, we:

  1. Delete the session from the database
  2. Clear the browser cookie with MaxAge: -1

Also added a test assertion to verify the cookie is properly cleared.

@tompscanlan
Copy link
Contributor

LGTM

@tompscanlan tompscanlan merged commit 80649fc into OpenMeet-Team:main Jan 4, 2026
3 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in OpenMeet Work Board Jan 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Clean up expired sessions in SessionMiddleware

2 participants