fix: use http utils in space access middleware

This commit is contained in:
juancwu 2026-02-23 14:54:01 +00:00
commit b329fb3e19

View file

@ -23,7 +23,7 @@ func RequireSpaceAccess(spaceService *service.SpaceService) func(http.HandlerFun
spaceID := r.PathValue("spaceID")
if spaceID == "" {
slog.Warn("RequireSpaceAccess middleware used on a route without a {spaceID} path parameter")
http.Error(w, "Not Found", http.StatusNotFound)
notfound(w, r)
return
}
@ -35,12 +35,7 @@ func RequireSpaceAccess(spaceService *service.SpaceService) func(http.HandlerFun
}
if !isMember {
if r.Header.Get("HX-Request") == "true" {
w.Header().Set("HX-Redirect", "/forbidden")
w.WriteHeader(http.StatusSeeOther)
return
}
http.Redirect(w, r, "/forbidden", http.StatusSeeOther)
redirect(w, r, "/forbidden", http.StatusSeeOther)
return
}