diff options
| author | mo khan <mo@mokhan.ca> | 2025-04-28 16:51:56 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-04-28 16:51:56 -0600 |
| commit | 059a87a80227426f854256139bbbc7309bdb6fa0 (patch) | |
| tree | ebd83f6a0f57133c9a34fffaf8c20ed6d62d9250 /app/controllers/sessions/controller.go | |
| parent | 37adeb5437d0f62f5dbc137bb98addcb9d891238 (diff) | |
feat: redirect to login page when session is established
Diffstat (limited to 'app/controllers/sessions/controller.go')
| -rw-r--r-- | app/controllers/sessions/controller.go | 6 |
1 files changed, 6 insertions, 0 deletions
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) |
