Clientside delete thread button

This commit is contained in:
Dominic Ferrando
2025-04-23 16:42:16 -04:00
parent e341c5d8c9
commit 62a1377be0
3 changed files with 67 additions and 7 deletions
+7 -1
View File
@@ -29,7 +29,13 @@ func AdminOnlyMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
c, err := r.Cookie("comfy_admin")
if err != nil || !util.IsAdminSessionValid(c.Value) {
http.Redirect(w, r, "/authorize", http.StatusSeeOther)
// Check if it's an HTMX request
if r.Header.Get("HX-Request") == "true" {
w.Header().Set("HX-Redirect", "/authorize")
w.WriteHeader(http.StatusOK)
} else {
http.Redirect(w, r, "/authorize", http.StatusSeeOther)
}
return
}
next.ServeHTTP(w, r)