From 885e3385aa78c6124fd092e753df2fc78d3ad9b3 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 17 May 2023 11:41:54 +0200 Subject: [PATCH] fix: send exhausted property in env json (#5877) --- internal/api/ui/console/console.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/api/ui/console/console.go b/internal/api/ui/console/console.go index 1980f6cc5f..ae8159c6eb 100644 --- a/internal/api/ui/console/console.go +++ b/internal/api/ui/console/console.go @@ -116,12 +116,13 @@ func Start(config Config, externalSecure bool, issuer op.IssuerFromRequest, call http.Error(w, fmt.Sprintf("unable to template instance management url for console: %v", err), http.StatusInternalServerError) return } - environmentJSON, err := createEnvironmentJSON(url, issuer(r), instance.ConsoleClientID(), customerPortal, instanceMgmtURL) + exhausted := limitingAccessInterceptor.Limit(ctx) + environmentJSON, err := createEnvironmentJSON(url, issuer(r), instance.ConsoleClientID(), customerPortal, instanceMgmtURL, exhausted) if err != nil { http.Error(w, fmt.Sprintf("unable to marshal env for console: %v", err), http.StatusInternalServerError) return } - if limitingAccessInterceptor.Limit(ctx) { + if exhausted { limitingAccessInterceptor.SetExhaustedCookie(w, r) } else { limitingAccessInterceptor.DeleteExhaustedCookie(w, r) @@ -154,19 +155,21 @@ func csp() *middleware.CSP { return &csp } -func createEnvironmentJSON(api, issuer, clientID, customerPortal, instanceMgmtUrl string) ([]byte, error) { +func createEnvironmentJSON(api, issuer, clientID, customerPortal, instanceMgmtUrl string, exhausted bool) ([]byte, error) { environment := struct { API string `json:"api,omitempty"` Issuer string `json:"issuer,omitempty"` ClientID string `json:"clientid,omitempty"` CustomerPortal string `json:"customer_portal,omitempty"` InstanceManagementURL string `json:"instance_management_url,omitempty"` + Exhausted bool `json:"exhausted,omitempty"` }{ API: api, Issuer: issuer, ClientID: clientID, CustomerPortal: customerPortal, InstanceManagementURL: instanceMgmtUrl, + Exhausted: exhausted, } return json.Marshal(environment) }