Skip to content

Commit

Permalink
Don't propagate "not exist" error if trying to erase a session matchi… (
Browse files Browse the repository at this point in the history
#252)

Summary of Changes

Don't consider "oserror.ErrNotExist" as a failure when trying to erase a
session which corresponds to a missing file.

Hello, in the current implementation, if a request contains a session
token that has been stored in a file that has been deleted and we're
trying to erase it using the Options.MaxAge = -1 workaround, the action
still fails, because the missing file error gets propagated higher in
the stack.

This small fix prevents this, and ensures that the session is
regenerated.
___

This is a reopen of #237 which was closed by the stale bot.

Co-authored-by: Corey Daley <cdaley@redhat.com>
  • Loading branch information
mariusor and coreydaley authored Aug 17, 2023
1 parent 69327c5 commit dd83328
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion store.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (s *FilesystemStore) Save(r *http.Request, w http.ResponseWriter,
session *Session) error {
// Delete if max-age is <= 0
if session.Options.MaxAge <= 0 {
if err := s.erase(session); err != nil {
if err := s.erase(session); err != nil && !os.IsNotExist(err) {
return err
}
http.SetCookie(w, NewCookie(session.Name(), "", session.Options))
Expand Down

0 comments on commit dd83328

Please sign in to comment.