fix(webui): display an error page in all error cases
All checks were successful
main / main (push) Successful in 1m48s
main / deploy (push) Has been skipped
main / publish (push) Has been skipped

This commit is contained in:
Julien Dessaux 2025-04-19 15:19:21 +02:00
parent c483d909f9
commit bb11b870d6
Signed by: adyxax
GPG key ID: F92E51B86E07177E
5 changed files with 11 additions and 6 deletions

View file

@ -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,
})