From 2cd89b747c7c255df9197132fcdf04d0c8cd2ff3 Mon Sep 17 00:00:00 2001 From: mo khan Date: Fri, 25 Apr 2025 10:16:54 -0600 Subject: feat: record the author of the new sparkle --- app/controllers/sparkles/controller.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'app/controllers/sparkles/controller.go') diff --git a/app/controllers/sparkles/controller.go b/app/controllers/sparkles/controller.go index 07a21ba..04eee12 100644 --- a/app/controllers/sparkles/controller.go +++ b/app/controllers/sparkles/controller.go @@ -9,6 +9,7 @@ import ( "github.com/xlgmokha/x/pkg/x" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/db" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/domain" + "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/web/middleware" ) type Controller struct { @@ -20,8 +21,10 @@ func New(db db.Repository[*domain.Sparkle]) *Controller { } func (c *Controller) MountTo(mux *http.ServeMux) { + requireUser := middleware.RequireUser(http.StatusFound, "/") + mux.HandleFunc("GET /sparkles", c.Index) - mux.HandleFunc("POST /sparkles", c.Create) + mux.Handle("POST /sparkles", requireUser(http.HandlerFunc(c.Create))) } func (c *Controller) Index(w http.ResponseWriter, r *http.Request) { -- cgit v1.2.3