Browse Source

Don't propagate "not exist" error if trying to erase a session matchi… (#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>
pull/268/head
Marius Orcsik 1 year ago committed by GitHub
parent
commit
dd83328c14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      store.go

2
store.go

@ -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))

Loading…
Cancel
Save