Skip to content

Commit

Permalink
fix: perform auth redirect on all cookie validation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jr0d committed Jun 16, 2020
1 parent e0a1ddf commit 327bb07
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions internal/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,8 @@ func (s *Server) AuthHandler(rule string) http.HandlerFunc {
// Validate cookie
email, err := ValidateCookie(r, c)
if err != nil {
if err.Error() == "cookie has expired" {
logger.Info("cookie has expired")
s.notAuthenticated(logger, w, r)
} else {
logger.Errorf("Invalid cookie: %v", err)
http.Error(w, "Not authorized", 401)
}
logger.Info(fmt.Sprintf("cookie validaton failure: %s", err.Error()))
s.notAuthenticated(logger, w, r)
return
}

Expand Down

0 comments on commit 327bb07

Please sign in to comment.