From bb11b870d62f7a2935a65345b70230f69366e286 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sat, 19 Apr 2025 15:19:21 +0200 Subject: [PATCH] fix(webui): display an error page in all error cases --- pkg/webui/error.go | 2 +- pkg/webui/html/accountsId.html | 2 +- pkg/webui/html/base.html | 5 +++++ pkg/webui/login.go | 6 +++--- pkg/webui/static/main.css | 2 +- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pkg/webui/error.go b/pkg/webui/error.go index 6e9815c..b1fcf4a 100644 --- a/pkg/webui/error.go +++ b/pkg/webui/error.go @@ -15,7 +15,7 @@ func errorResponse(w http.ResponseWriter, r *http.Request, status int, err error StatusText string } render(w, errorTemplates, status, &ErrorData{ - Page: makePage(r, &Page{Title: "Error", Section: "error"}), + Page: &Page{Title: "Error", Section: "error"}, Err: err, Status: status, StatusText: http.StatusText(status), diff --git a/pkg/webui/html/accountsId.html b/pkg/webui/html/accountsId.html index 9bfe95c..52c4cef 100644 --- a/pkg/webui/html/accountsId.html +++ b/pkg/webui/html/accountsId.html @@ -3,7 +3,7 @@ {{ if ne .Account.PasswordReset nil }}

Password Reset

- Direct the user to /account/{{ .Account.Id }}/reset/{{ .Account.PasswordReset }} so that they can create their password. + Direct the user to /accounts/{{ .Account.Id }}/reset/{{ .Account.PasswordReset }} so that they can create their password.
{{ end }}

Status

diff --git a/pkg/webui/html/base.html b/pkg/webui/html/base.html index c8732c7..81e39a6 100644 --- a/pkg/webui/html/base.html +++ b/pkg/webui/html/base.html @@ -19,6 +19,11 @@ login Login + {{ else if eq .Page.Section "error" }} + + mountain_flag + TfStated + {{ else }} home_storage diff --git a/pkg/webui/login.go b/pkg/webui/login.go index c5b1572..f6762e7 100644 --- a/pkg/webui/login.go +++ b/pkg/webui/login.go @@ -18,7 +18,7 @@ var loginTemplate = template.Must(template.ParseFS(htmlFS, "html/base.html", "ht var validUsername = regexp.MustCompile(`^[a-zA-Z]\w*$`) type loginPage struct { - Page + Page *Page Forbidden bool Username string } @@ -34,7 +34,7 @@ func handleLoginGET() http.Handler { } render(w, loginTemplate, http.StatusOK, loginPage{ - Page: Page{Title: "Login", Section: "login"}, + Page: &Page{Title: "Login", Section: "login"}, }) }) } @@ -42,7 +42,7 @@ func handleLoginGET() http.Handler { func handleLoginPOST(db *database.DB) http.Handler { renderForbidden := func(w http.ResponseWriter, username string) { render(w, loginTemplate, http.StatusForbidden, loginPage{ - Page: Page{Title: "Login", Section: "login"}, + Page: &Page{Title: "Login", Section: "login"}, Forbidden: true, Username: username, }) diff --git a/pkg/webui/static/main.css b/pkg/webui/static/main.css index 4658d65..ed24230 100644 --- a/pkg/webui/static/main.css +++ b/pkg/webui/static/main.css @@ -284,7 +284,7 @@ button:hover { gap: 4px; } .flex-row { - align-items: start; + align-items: center; display: flex; flex-direction: row; gap: 16px;