Skip to content

Commit

Permalink
Fix session not returning and adding panic in case of fail as this sh…
Browse files Browse the repository at this point in the history
…ould never fail
  • Loading branch information
COMTOP1 committed Oct 9, 2023
1 parent 86fd3a4 commit 56b8db0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion views/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ func (v *Views) RequiresLogin(next echo.HandlerFunc) echo.HandlerFunc {
session, err := v.cookie.Get(c.Request(), v.conf.SessionCookieName)
if err != nil {
log.Printf("failed to get session: %+v", err)
session.Options.MaxAge = -1
session, err = v.cookie.New(c.Request(), v.conf.SessionCookieName)
if err != nil {
panic(fmt.Errorf("failed to make new session: %w", err))
}
err = session.Save(c.Request(), c.Response())
if err != nil {
log.Printf("failed to save session for logout: %+v", err)
Expand Down

0 comments on commit 56b8db0

Please sign in to comment.