package middleware import ( "net/http" "github.com/xlgmokha/x/pkg/x" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/key" ) func RequireUser(code int, url string) func(http.Handler) http.Handler { return func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { user := key.CurrentUser.From(r.Context()) if x.IsZero(user) { http.Redirect(w, r, url, code) return } next.ServeHTTP(w, r) }) } }