@@ -11738,20 +11738,6 @@ func HandleChangeUserOrg(resp http.ResponseWriter, request *http.Request) {
1173811738 Mode string `json:"mode"`
1173911739 }
1174011740
11741- var tmpData ReturnData
11742- err = json.Unmarshal(body, &tmpData)
11743- if err != nil {
11744- log.Printf("Failed unmarshalling test: %s", err)
11745- resp.WriteHeader(401)
11746- resp.Write([]byte(`{"success": false}`))
11747- return
11748- }
11749-
11750- if tmpData.SSOTest || tmpData.SSO {
11751- tmpData.SSOTest = true
11752- tmpData.SSO = true
11753- }
11754-
1175511741 var fileId string
1175611742 location := strings.Split(request.URL.String(), "/")
1175711743 if location[1] == "api" {
@@ -11765,6 +11751,25 @@ func HandleChangeUserOrg(resp http.ResponseWriter, request *http.Request) {
1176511751 fileId = location[4]
1176611752 }
1176711753
11754+ var tmpData ReturnData
11755+ err = json.Unmarshal(body, &tmpData)
11756+ if err != nil {
11757+ if len(fileId) == 36 && strings.Count(fileId, "-") == 4 {
11758+ log.Printf("[DEBUG] Empty body in change org, using fileId from URL: %s", fileId)
11759+ tmpData.OrgId = fileId
11760+ } else {
11761+ log.Printf("[WARNING] Failed unmarshalling change org body: %s", err)
11762+ resp.WriteHeader(401)
11763+ resp.Write([]byte(`{"success": false}`))
11764+ return
11765+ }
11766+ }
11767+
11768+ if tmpData.SSOTest || tmpData.SSO {
11769+ tmpData.SSOTest = true
11770+ tmpData.SSO = true
11771+ }
11772+
1176811773 foundOrg := false
1176911774 for _, org := range user.Orgs {
1177011775 if org == tmpData.OrgId {
@@ -21226,7 +21231,7 @@ func PrepareSingleAction(ctx context.Context, user User, appId string, body []by
2122621231 }
2122721232
2122821233 if param.Name == "url" {
21229- action.Parameters[paramIndex].Value = apiUrl
21234+ action.Parameters[paramIndex].Value = apiUrl
2123021235 urlFound = true
2123121236 } else if param.Name == "apikey" {
2123221237 action.Parameters[paramIndex].Value = apiKey
@@ -21258,7 +21263,7 @@ func PrepareSingleAction(ctx context.Context, user User, appId string, body []by
2125821263 workflow.OrgId = "INTERNAL"
2125921264 workflow.ExecutingOrg = OrgMini{
2126021265 Name: "INTERNAL",
21261- Id: "INTERNAL",
21266+ Id: "INTERNAL",
2126221267 }
2126321268
2126421269 workflowExecution.Workflow = workflow
@@ -24130,17 +24135,17 @@ func PrepareWorkflowExecution(ctx context.Context, workflow Workflow, request *h
2413024135
2413124136 decision.RunDetails.Status = "RUNNING"
2413224137 decision.Fields = append(decision.Fields, Valuereplace{
24133- Key: "approve",
24134- Value: fmt.Sprintf("Approved to continue at %s", time.Now().Format(time.RFC1123)),
24138+ Key: "approve",
24139+ Value: fmt.Sprintf("Approved to continue at %s", time.Now().Format(time.RFC1123)),
2413524140 })
2413624141
2413724142 fieldsChanged = true
2413824143 cleanupFailures = true
24139- } else if value == "false" {
24144+ } else if value == "false" {
2414024145 decision.RunDetails.Status = "FINISHED"
2414124146 decision.Fields = append(decision.Fields, Valuereplace{
24142- Key: "approve",
24143- Value: fmt.Sprintf("Approval DENIED at %s. Should stop the agent.", time.Now().Unix()),
24147+ Key: "approve",
24148+ Value: fmt.Sprintf("Approval DENIED at %s. Should stop the agent.", time.Now().Unix()),
2414424149 })
2414524150
2414624151 fieldsChanged = true
@@ -24153,7 +24158,6 @@ func PrepareWorkflowExecution(ctx context.Context, workflow Workflow, request *h
2415324158 break
2415424159 }
2415524160
24156-
2415724161 if findContinue {
2415824162 // The only key we care about in this case
2415924163 if key == "continue" {
0 commit comments