mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-22 01:13:00 +02:00
webui: configure, restore HX-Trigger on save error
renderSaveError lost the HX-Trigger header during the Configure-mode
fold, leaving forms with hx-swap="none" silent on validation errors.
Re-emit `{"cfgError":...}` so the toast layer still gets the event.
DeleteKey's response goes back to a bare 200 to match the other
configure_users.go endpoints; the activity-log redirect form belongs
on the Add/Edit flows.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -381,9 +381,8 @@ func renderSaveError(w http.ResponseWriter, err error) {
|
||||
msg = err.Error()
|
||||
}
|
||||
w.Header().Set("Content-Type", "text/html")
|
||||
w.WriteHeader(http.StatusUnprocessableEntity)
|
||||
// Encode the message safely for HTML output.
|
||||
b, _ := json.Marshal(msg)
|
||||
_ = b // used below via template-escaped string
|
||||
w.Header().Set("HX-Trigger", `{"cfgError":`+string(b)+`}`)
|
||||
w.WriteHeader(http.StatusUnprocessableEntity)
|
||||
w.Write([]byte(`<span class="cfg-save-error">` + template.HTMLEscapeString(msg) + `</span>`))
|
||||
}
|
||||
|
||||
@@ -339,6 +339,7 @@ func (h *ConfigureUsersHandler) DeleteKey(w http.ResponseWriter, r *http.Request
|
||||
renderSaveError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
var userEntry map[string]any
|
||||
for _, u := range raw.System.Auth.Users {
|
||||
if u.Name != name {
|
||||
@@ -390,7 +391,7 @@ func (h *ConfigureUsersHandler) DeleteKey(w http.ResponseWriter, r *http.Request
|
||||
renderSaveError(w, err)
|
||||
return
|
||||
}
|
||||
renderSavedRedirect(w, "SSH key deleted", "/configure/users")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
// fetchAllGroups reads NACM groups from candidate, falling back to running on 404.
|
||||
|
||||
Reference in New Issue
Block a user