lack of seesions allowd for anonymose auth
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user