summaryrefslogtreecommitdiff
path: root/app/controllers/sparkles/controller.go
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-07-23 12:40:12 -0600
committermo khan <mo@mokhan.ca>2025-07-23 12:40:12 -0600
commitd2ebd0a9afed57ba11f053266e6ae1edb84a0f36 (patch)
treeeb547006085f2549f2cea5773c1ec75dba47bfd0 /app/controllers/sparkles/controller.go
parent9674cfaedfdb8d583cfe75e1c1738a1c1d66c7f9 (diff)
feat: authorize requests to create sparkles
Diffstat (limited to 'app/controllers/sparkles/controller.go')
-rw-r--r--app/controllers/sparkles/controller.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/app/controllers/sparkles/controller.go b/app/controllers/sparkles/controller.go
index 80e95cb..ef2ecd5 100644
--- a/app/controllers/sparkles/controller.go
+++ b/app/controllers/sparkles/controller.go
@@ -14,11 +14,15 @@ import (
)
type Controller struct {
- db domain.Repository[*domain.Sparkle]
+ db domain.Repository[*domain.Sparkle]
+ check authz.CheckPermissionService
}
-func New(db domain.Repository[*domain.Sparkle], check authz.PermissionService) *Controller {
- return &Controller{db: db}
+func New(db domain.Repository[*domain.Sparkle], check authz.CheckPermissionService) *Controller {
+ return &Controller{
+ check: check,
+ db: db,
+ }
}
func (c *Controller) MountTo(mux *http.ServeMux) {
@@ -26,7 +30,7 @@ func (c *Controller) MountTo(mux *http.ServeMux) {
mux.Handle("POST /sparkles", x.Middleware[http.Handler](
http.HandlerFunc(c.Create),
middleware.RequireUser(),
- // middleware.RequirePermission("create", x.Try(ioc.Resolve[authz.CheckPermission](ioc.Default))),
+ middleware.RequirePermission("create", c.check),
))
// This is a temporary endpoint to restore a backup