fix: use http utils in space access middleware
This commit is contained in:
parent
0a2ab751a5
commit
b329fb3e19
1 changed files with 2 additions and 7 deletions
|
|
@ -23,7 +23,7 @@ func RequireSpaceAccess(spaceService *service.SpaceService) func(http.HandlerFun
|
||||||
spaceID := r.PathValue("spaceID")
|
spaceID := r.PathValue("spaceID")
|
||||||
if spaceID == "" {
|
if spaceID == "" {
|
||||||
slog.Warn("RequireSpaceAccess middleware used on a route without a {spaceID} path parameter")
|
slog.Warn("RequireSpaceAccess middleware used on a route without a {spaceID} path parameter")
|
||||||
http.Error(w, "Not Found", http.StatusNotFound)
|
notfound(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -35,12 +35,7 @@ func RequireSpaceAccess(spaceService *service.SpaceService) func(http.HandlerFun
|
||||||
}
|
}
|
||||||
|
|
||||||
if !isMember {
|
if !isMember {
|
||||||
if r.Header.Get("HX-Request") == "true" {
|
redirect(w, r, "/forbidden", http.StatusSeeOther)
|
||||||
w.Header().Set("HX-Redirect", "/forbidden")
|
|
||||||
w.WriteHeader(http.StatusSeeOther)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
http.Redirect(w, r, "/forbidden", http.StatusSeeOther)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue