diff options
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/dashboard/controller.go | 7 | ||||
| -rw-r--r-- | app/controllers/dashboard/controller_test.go | 3 |
2 files changed, 4 insertions, 6 deletions
diff --git a/app/controllers/dashboard/controller.go b/app/controllers/dashboard/controller.go index d805027..b27ebe1 100644 --- a/app/controllers/dashboard/controller.go +++ b/app/controllers/dashboard/controller.go @@ -4,13 +4,10 @@ import ( "html/template" "net/http" - "github.com/xlgmokha/x/pkg/context" "github.com/xlgmokha/x/pkg/x" - "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/domain" + "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/key" ) -var CurrentUserKey context.Key[*domain.User] = context.Key[*domain.User]("current_user") - type Controller struct { } @@ -23,7 +20,7 @@ func (c *Controller) MountTo(mux *http.ServeMux) { } func (c *Controller) Show(w http.ResponseWriter, r *http.Request) { - currentUser := CurrentUserKey.From(r.Context()) + currentUser := key.CurrentUserKey.From(r.Context()) if x.IsZero(currentUser) { http.Redirect(w, r, "/", http.StatusFound) diff --git a/app/controllers/dashboard/controller_test.go b/app/controllers/dashboard/controller_test.go index ff2482f..b8199c4 100644 --- a/app/controllers/dashboard/controller_test.go +++ b/app/controllers/dashboard/controller_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/assert" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/domain" + "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/key" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/test" ) @@ -29,7 +30,7 @@ func TestController(t *testing.T) { t.Run("when authenticated", func(t *testing.T) { t.Run("renders a dashboard page", func(t *testing.T) { - ctx := CurrentUserKey.With(t.Context(), &domain.User{}) + ctx := key.CurrentUserKey.With(t.Context(), &domain.User{}) r, w := test.RequestResponse("GET", "/dashboard", test.WithContext(ctx)) mux.ServeHTTP(w, r) |
