lack of seesions allowd for anonymose auth

This commit is contained in:
Umputun
2017-12-28 23:53:35 -06:00
parent 5f61857c0f
commit 800c170d15
2 changed files with 7 additions and 5 deletions
+7 -2
View File
@@ -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
}
-3
View File
@@ -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
}