diff options
| author | mo khan <mo@mokhan.ca> | 2025-04-16 13:43:38 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-04-16 13:43:38 -0600 |
| commit | d24708251deb598c522a67e6615d3403d65dbcdc (patch) | |
| tree | 6f8989aaedd0ba5a9cf2450a7f6097ec2e2b1fb2 /app/controllers/dashboard/controller.go | |
| parent | b7ff80b7be532f4bb64c1daf8cef3462f9938362 (diff) | |
feat: render an html page when a user is logged in
Diffstat (limited to 'app/controllers/dashboard/controller.go')
| -rw-r--r-- | app/controllers/dashboard/controller.go | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/app/controllers/dashboard/controller.go b/app/controllers/dashboard/controller.go index 060dbfa..cd1c44f 100644 --- a/app/controllers/dashboard/controller.go +++ b/app/controllers/dashboard/controller.go @@ -1,6 +1,14 @@ package dashboard -import "net/http" +import ( + "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" +) + +var CurrentUserKey context.Key[*domain.User] = context.Key[*domain.User]("current_user") type Controller struct { } @@ -14,5 +22,13 @@ func (c *Controller) MountTo(mux *http.ServeMux) { } func (c *Controller) Show(w http.ResponseWriter, r *http.Request) { - http.Redirect(w, r, "/", http.StatusFound) + currentUser := CurrentUserKey.From(r.Context()) + + if x.IsZero(currentUser) { + http.Redirect(w, r, "/", http.StatusFound) + return + } + + w.WriteHeader(http.StatusOK) + w.Header().Add("Content-Type", "text/html") } |
