From d24708251deb598c522a67e6615d3403d65dbcdc Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 16 Apr 2025 13:43:38 -0600 Subject: feat: render an html page when a user is logged in --- app/controllers/dashboard/controller.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'app/controllers/dashboard/controller.go') 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") } -- cgit v1.2.3