diff --git a/comments/comments.go b/comments/comments.go index 1ea3719..3f4bc44 100644 --- a/comments/comments.go +++ b/comments/comments.go @@ -68,6 +68,7 @@ func (cs *Service) User(r *http.Request) (string, bool) { func (cs *Service) ServeComments(post string, w http.ResponseWriter, r *http.Request) error { user, allowed := cs.User(r) if !allowed { + fmt.Fprintf(w, "click here to enter your name and the comments password") w.WriteHeader(401) return nil } diff --git a/http.go b/http.go index 5bfbbe6..eb83273 100644 --- a/http.go +++ b/http.go @@ -119,10 +119,6 @@ func (ch *CaddyHugo) Auth(r *http.Request) bool { return true } -func (ch *CaddyHugo) CommentAuth(r *http.Request) bool { - return true -} - func (ch *CaddyHugo) Match(r *http.Request) bool { if strings.HasPrefix(r.URL.Path, "/media/") { return true @@ -259,13 +255,13 @@ func (ch *CaddyHugo) commentsLogin(r *http.Request, w http.ResponseWriter) (int, _, ok := ch.Comments.User(r) if !ok { - w.Header().Set("WWW-Authenticate", `Basic realm="Give your name and the password. Ask Dan or Stephen for the password.`) - return 401, nil + w.Header().Set("WWW-Authenticate", `Basic realm="Log in with your name and the password. Ask Dan or Stephen for the password."`) + w.WriteHeader(401) + fmt.Fprintf(w, "Log in with your name and the password. Ask Dan or Stephen for the password. go back", r.Referer()) + return 200, nil } - if strings.HasSuffix(r.Referer(), "/comments") { - http.Redirect(w, r, r.Referer(), http.StatusFound) - } + http.Redirect(w, r, r.Referer(), http.StatusFound) return 200, nil }