From 32c8f0cfa03a282ae75c3edd46f04c0317d19dab Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Sat, 4 Jul 2020 15:03:37 +0200 Subject: [PATCH] Always redirect to homepage when not logged in --- main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/main.go b/main.go index 706a5a3..2546c73 100644 --- a/main.go +++ b/main.go @@ -473,6 +473,11 @@ func (h *graphHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } }() + if !sess.LoggedIn { + http.Redirect(w, r, "/", http.StatusFound) + return + } + refs := make(Refs) f, err := os.Open(filepath.Join(mp.(*FilePages).dirname, "backrefs.json")) @@ -613,6 +618,11 @@ func (h *indexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } }() + if !sess.LoggedIn { + http.Redirect(w, r, "/", http.StatusFound) + return + } + format := r.URL.Query().Get("format") if format == "" { format = "html"