Skip to content

Commit

Permalink
Clear authenticated session if unable to read cookie (#764)
Browse files Browse the repository at this point in the history
  • Loading branch information
InfiniteStash committed Feb 27, 2024
1 parent f9bead0 commit 61e8dcb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/api/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ func handleLogout(w http.ResponseWriter, r *http.Request) {
func getSessionUserID(w http.ResponseWriter, r *http.Request) (string, error) {
session, err := sessionStore.Get(r, cookieName)
if err != nil {
return "", err
session.Options.MaxAge = -1
if err = session.Save(r, w); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
return "", nil
}

if !session.IsNew {
Expand Down

0 comments on commit 61e8dcb

Please sign in to comment.