summaryrefslogtreecommitdiff
path: root/app/middleware/require_user.go
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-04-25 16:29:45 -0600
committermo khan <mo@mokhan.ca>2025-04-28 09:07:31 -0600
commit10acef83528c746abeb597490d516a55b5a0955e (patch)
tree16979017ec6579b24afc84fb2ac02301cc7edef3 /app/middleware/require_user.go
parent6f03359ac68865d31c26c4600d79c3e985f002b4 (diff)
fix: render 404 when not logged in
Diffstat (limited to 'app/middleware/require_user.go')
-rw-r--r--app/middleware/require_user.go15
1 files changed, 5 insertions, 10 deletions
diff --git a/app/middleware/require_user.go b/app/middleware/require_user.go
index 8df4fd7..d0d5355 100644
--- a/app/middleware/require_user.go
+++ b/app/middleware/require_user.go
@@ -2,21 +2,16 @@ package middleware
import (
"net/http"
-
- "github.com/xlgmokha/x/pkg/x"
- "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/cfg"
)
-func RequireUser(code int, url string) func(http.Handler) http.Handler {
+func RequireUser() func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- user := cfg.CurrentUser.From(r.Context())
- if x.IsZero(user) {
- http.Redirect(w, r, url, code)
- return
+ if IsLoggedIn(r) {
+ next.ServeHTTP(w, r)
+ } else {
+ w.WriteHeader(http.StatusNotFound)
}
-
- next.ServeHTTP(w, r)
})
}
}