diff --git a/app/rest/auth/middleware.go b/app/rest/auth/middleware.go index 2d8a5d52..b0a0cede 100644 --- a/app/rest/auth/middleware.go +++ b/app/rest/auth/middleware.go @@ -56,8 +56,13 @@ func Auth(sessionStore *sessions.FilesystemStore, admins []string, modes []Mode) } session, err := sessionStore.Get(r, "remark") - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) + if err != nil && inModes(Full) { // in full auth lack of session causes Unauthorized + http.Error(w, err.Error(), http.StatusUnauthorized) + return + } + + if err != nil { // in any other mode just pass it to next handler + h.ServeHTTP(w, r) return } diff --git a/app/rest/server.go b/app/rest/server.go index 54642395..0e18ba7f 100644 --- a/app/rest/server.go +++ b/app/rest/server.go @@ -184,7 +184,6 @@ func (s *Server) findCommentsCtrl(w http.ResponseWriter, r *http.Request) { cacheKey := r.URL.String() if comments, ok := s.respCache.Get(cacheKey); ok { - log.Printf("[DEBUG] cash hit for %s", cacheKey) renderJSONWithHTML(w, r, comments) return } @@ -215,7 +214,6 @@ func (s *Server) lastCommentsCtrl(w http.ResponseWriter, r *http.Request) { cacheKey := r.URL.String() if comments, ok := s.respCache.Get(cacheKey); ok { - log.Printf("[DEBUG] cash hit for %s", cacheKey) renderJSONWithHTML(w, r, comments) return } @@ -259,7 +257,6 @@ func (s *Server) findUserCommentsCtrl(w http.ResponseWriter, r *http.Request) { cacheKey := r.URL.String() if comments, ok := s.respCache.Get(cacheKey); ok { - log.Printf("[DEBUG] cash hit for %s", cacheKey) renderJSONWithHTML(w, r, comments) return }