From f7bc6c6216623173d79fc3c720cadeb507e9da0a Mon Sep 17 00:00:00 2001 From: Unbewohnte Date: Mon, 28 Oct 2024 16:31:29 +0300 Subject: [PATCH] Bugfix: Fixed trying to access invalid group not redirecting to error page --- src/server/server.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/server/server.go b/src/server/server.go index 91bc299..f8bf6b9 100644 --- a/src/server/server.go +++ b/src/server/server.go @@ -154,6 +154,13 @@ func New(config conf.Conf) (*Server, error) { return } + // Check if it exists + if _, err = server.db.GetTodoGroup(groupId); err != nil { + // Group does not exist + http.Redirect(w, req, "/error", http.StatusTemporaryRedirect) + return + } + requestedPage, err := getPage( filepath.Join(server.config.BaseContentDir, PagesDirName), "base.html", "category.html", ) @@ -183,7 +190,6 @@ func New(config conf.Conf) (*Server, error) { if err == nil { requestedPage.ExecuteTemplate(w, req.URL.Path[1:]+".html", nil) } else { - // http.Error(w, "Page processing error", http.StatusInternalServerError) http.Redirect(w, req, "/error", http.StatusTemporaryRedirect) } }