diff options
| author | mo khan <mo@mokhan.ca> | 2025-05-28 18:31:00 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-05-28 18:31:00 -0600 |
| commit | cf1050dba0f0b0b26d18ce45ae2c8821153759bd (patch) | |
| tree | e3f67d0f2c47015d48f725cb9afb55282b5617c2 /app/controllers/dashboard | |
| parent | 6951a69bff4d633b7fa8805e916c25b204373d9d (diff) | |
| parent | e5bc1eb2b71d46958088f1c62e69e1074e9f8026 (diff) | |
Merge branch '11/x-jwt-payload' into 'main'
Read trusted identity information from envoy headers
See merge request gitlab-org/software-supply-chain-security/authorization/sparkled!14
Diffstat (limited to 'app/controllers/dashboard')
| -rw-r--r-- | app/controllers/dashboard/controller.go | 6 | ||||
| -rw-r--r-- | app/controllers/dashboard/controller_test.go | 3 |
2 files changed, 4 insertions, 5 deletions
diff --git a/app/controllers/dashboard/controller.go b/app/controllers/dashboard/controller.go index 04a7ed1..d279930 100644 --- a/app/controllers/dashboard/controller.go +++ b/app/controllers/dashboard/controller.go @@ -41,14 +41,12 @@ func (c *Controller) Show(w http.ResponseWriter, r *http.Request) { } func (c *Controller) Navigation(w http.ResponseWriter, r *http.Request) { - currentUser := cfg.CurrentUser.From(r.Context()) - w.WriteHeader(http.StatusOK) w.Header().Add("Content-Type", "text/html") dto := &NavigationDTO{ - CurrentUser: currentUser, - IsLoggedIn: currentUser != nil, + CurrentUser: cfg.CurrentUser.From(r.Context()), + IsLoggedIn: middleware.IsLoggedIn(r), } if err := views.Render(w, "dashboard/nav", dto); err != nil { pls.LogError(r.Context(), err) diff --git a/app/controllers/dashboard/controller_test.go b/app/controllers/dashboard/controller_test.go index c717a74..ddbfd34 100644 --- a/app/controllers/dashboard/controller_test.go +++ b/app/controllers/dashboard/controller_test.go @@ -28,7 +28,7 @@ func TestController(t *testing.T) { }) t.Run("when authenticated", func(t *testing.T) { - ctx := cfg.CurrentUser.With(t.Context(), &domain.User{}) + ctx := cfg.CurrentUser.With(t.Context(), &domain.User{ID: domain.ID("1")}) r, w := test.RequestResponse("GET", "/dashboard", test.WithContext(ctx)) mux.ServeHTTP(w, r) @@ -55,6 +55,7 @@ func TestController(t *testing.T) { t.Run("when authenticated", func(t *testing.T) { ctx := cfg.CurrentUser.With(t.Context(), &domain.User{ + ID: domain.ID("1"), Username: "root", }) r, w := test.RequestResponse("GET", "/dashboard/nav", test.WithContext(ctx)) |
