@@ -11746,20 +11746,6 @@ func HandleChangeUserOrg(resp http.ResponseWriter, request *http.Request) {
1174611746 Mode string `json:"mode"`
1174711747 }
1174811748
11749- var tmpData ReturnData
11750- err = json.Unmarshal(body, &tmpData)
11751- if err != nil {
11752- log.Printf("Failed unmarshalling test: %s", err)
11753- resp.WriteHeader(401)
11754- resp.Write([]byte(`{"success": false}`))
11755- return
11756- }
11757-
11758- if tmpData.SSOTest || tmpData.SSO {
11759- tmpData.SSOTest = true
11760- tmpData.SSO = true
11761- }
11762-
1176311749 var fileId string
1176411750 location := strings.Split(request.URL.String(), "/")
1176511751 if location[1] == "api" {
@@ -11773,6 +11759,25 @@ func HandleChangeUserOrg(resp http.ResponseWriter, request *http.Request) {
1177311759 fileId = location[4]
1177411760 }
1177511761
11762+ var tmpData ReturnData
11763+ err = json.Unmarshal(body, &tmpData)
11764+ if err != nil {
11765+ if len(fileId) == 36 && strings.Count(fileId, "-") == 4 {
11766+ log.Printf("[DEBUG] Empty body in change org, using fileId from URL: %s", fileId)
11767+ tmpData.OrgId = fileId
11768+ } else {
11769+ log.Printf("[WARNING] Failed unmarshalling change org body: %s", err)
11770+ resp.WriteHeader(401)
11771+ resp.Write([]byte(`{"success": false}`))
11772+ return
11773+ }
11774+ }
11775+
11776+ if tmpData.SSOTest || tmpData.SSO {
11777+ tmpData.SSOTest = true
11778+ tmpData.SSO = true
11779+ }
11780+
1177611781 foundOrg := false
1177711782 for _, org := range user.Orgs {
1177811783 if org == tmpData.OrgId {
@@ -21234,7 +21239,7 @@ func PrepareSingleAction(ctx context.Context, user User, appId string, body []by
2123421239 }
2123521240
2123621241 if param.Name == "url" {
21237- action.Parameters[paramIndex].Value = apiUrl
21242+ action.Parameters[paramIndex].Value = apiUrl
2123821243 urlFound = true
2123921244 } else if param.Name == "apikey" {
2124021245 action.Parameters[paramIndex].Value = apiKey
@@ -21266,7 +21271,7 @@ func PrepareSingleAction(ctx context.Context, user User, appId string, body []by
2126621271 workflow.OrgId = "INTERNAL"
2126721272 workflow.ExecutingOrg = OrgMini{
2126821273 Name: "INTERNAL",
21269- Id: "INTERNAL",
21274+ Id: "INTERNAL",
2127021275 }
2127121276
2127221277 workflowExecution.Workflow = workflow
@@ -24138,17 +24143,17 @@ func PrepareWorkflowExecution(ctx context.Context, workflow Workflow, request *h
2413824143
2413924144 decision.RunDetails.Status = "RUNNING"
2414024145 decision.Fields = append(decision.Fields, Valuereplace{
24141- Key: "approve",
24142- Value: fmt.Sprintf("Approved to continue at %s", time.Now().Format(time.RFC1123)),
24146+ Key: "approve",
24147+ Value: fmt.Sprintf("Approved to continue at %s", time.Now().Format(time.RFC1123)),
2414324148 })
2414424149
2414524150 fieldsChanged = true
2414624151 cleanupFailures = true
24147- } else if value == "false" {
24152+ } else if value == "false" {
2414824153 decision.RunDetails.Status = "FINISHED"
2414924154 decision.Fields = append(decision.Fields, Valuereplace{
24150- Key: "approve",
24151- Value: fmt.Sprintf("Approval DENIED at %s. Should stop the agent.", time.Now().Unix()),
24155+ Key: "approve",
24156+ Value: fmt.Sprintf("Approval DENIED at %s. Should stop the agent.", time.Now().Unix()),
2415224157 })
2415324158
2415424159 fieldsChanged = true
@@ -24161,7 +24166,6 @@ func PrepareWorkflowExecution(ctx context.Context, workflow Workflow, request *h
2416124166 break
2416224167 }
2416324168
24164-
2416524169 if findContinue {
2416624170 // The only key we care about in this case
2416724171 if key == "continue" {
0 commit comments