fix(webui): display an error page in all error cases
This commit is contained in:
parent
c483d909f9
commit
bb11b870d6
5 changed files with 11 additions and 6 deletions
|
@ -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),
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
{{ if ne .Account.PasswordReset nil }}
|
||||
<h2>Password Reset</h2>
|
||||
<article>
|
||||
Direct the user to <a href="/account/{{ .Account.Id }}/reset/{{ .Account.PasswordReset }}">/account/{{ .Account.Id }}/reset/{{ .Account.PasswordReset }}</a> so that they can create their password.
|
||||
Direct the user to <a href="/accounts/{{ .Account.Id }}/reset/{{ .Account.PasswordReset }}">/accounts/{{ .Account.Id }}/reset/{{ .Account.PasswordReset }}</a> so that they can create their password.
|
||||
</article>
|
||||
{{ end }}
|
||||
<h2>Status</h2>
|
||||
|
|
|
@ -19,6 +19,11 @@
|
|||
<i class="material-symbols-outlined">login</i>
|
||||
<span>Login</span>
|
||||
</a>
|
||||
{{ else if eq .Page.Section "error" }}
|
||||
<a href="/">
|
||||
<i class="material-symbols-outlined">mountain_flag</i>
|
||||
<span>TfStated</span>
|
||||
</a>
|
||||
{{ else }}
|
||||
<a href="/states"{{ if eq .Page.Section "states" }} class="primary"{{ end}}>
|
||||
<i class="material-symbols-outlined">home_storage</i>
|
||||
|
|
|
@ -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,
|
||||
})
|
||||
|
|
|
@ -284,7 +284,7 @@ button:hover {
|
|||
gap: 4px;
|
||||
}
|
||||
.flex-row {
|
||||
align-items: start;
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 16px;
|
||||
|
|
Loading…
Add table
Reference in a new issue