diff options
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") } |
