From 059a87a80227426f854256139bbbc7309bdb6fa0 Mon Sep 17 00:00:00 2001 From: mo khan Date: Mon, 28 Apr 2025 16:51:56 -0600 Subject: feat: redirect to login page when session is established --- app/controllers/sessions/controller.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app/controllers/sessions/controller.go') diff --git a/app/controllers/sessions/controller.go b/app/controllers/sessions/controller.go index 25c215e..e2f4b22 100644 --- a/app/controllers/sessions/controller.go +++ b/app/controllers/sessions/controller.go @@ -5,6 +5,7 @@ import ( "time" "github.com/xlgmokha/x/pkg/log" + "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/middleware" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/oidc" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/web/cookie" ) @@ -26,6 +27,11 @@ func (c *Controller) MountTo(mux *http.ServeMux) { } func (c *Controller) New(w http.ResponseWriter, r *http.Request) { + if middleware.IsLoggedIn(r) { + http.Redirect(w, r, "/dashboard", http.StatusFound) + return + } + url, nonce := c.svc.GenerateRedirectURL() http.SetCookie(w, cookie.New("oauth_state", nonce, time.Now().Add(10*time.Minute))) http.Redirect(w, r, url, http.StatusFound) -- cgit v1.2.3