Skip to content

Commit d4f72c0

Browse files
committed
Fixed the workflow import system to actually have the right nodes
1 parent 084438d commit d4f72c0

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

shared.go

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7750,7 +7750,7 @@ func SaveWorkflow(resp http.ResponseWriter, request *http.Request) {
77507750

77517751
if user.Role == "org-reader" {
77527752
log.Printf("[WARNING] Org-reader doesn't have access to save workflow (2): %s (%s)", user.Username, user.Id)
7753-
resp.WriteHeader(401)
7753+
resp.WriteHeader(403)
77547754
resp.Write([]byte(`{"success": false, "reason": "Read only user"}`))
77557755
return
77567756
}
@@ -7773,7 +7773,7 @@ func SaveWorkflow(resp http.ResponseWriter, request *http.Request) {
77737773

77747774
if len(fileId) != 36 {
77757775
log.Printf(`[WARNING] Workflow ID %s is not valid`, fileId)
7776-
resp.WriteHeader(401)
7776+
resp.WriteHeader(400)
77777777
resp.Write([]byte(`{"success": false, "reason": "Workflow ID to save is not valid"}`))
77787778
return
77797779
}
@@ -7783,7 +7783,7 @@ func SaveWorkflow(resp http.ResponseWriter, request *http.Request) {
77837783
tmpworkflow, err := GetWorkflow(ctx, fileId)
77847784
if err != nil {
77857785
log.Printf("[WARNING] Failed getting the workflow %s locally (save workflow): %s", fileId, err)
7786-
resp.WriteHeader(401)
7786+
resp.WriteHeader(400)
77877787
resp.Write([]byte(`{"success": false}`))
77887788
return
77897789
}
@@ -7792,7 +7792,7 @@ func SaveWorkflow(resp http.ResponseWriter, request *http.Request) {
77927792
body, err := ioutil.ReadAll(request.Body)
77937793
if err != nil {
77947794
log.Printf("[WARNING] Failed workflow body read: %s", err)
7795-
resp.WriteHeader(401)
7795+
resp.WriteHeader(400)
77967796
resp.Write([]byte(`{"success": false}`))
77977797
return
77987798
}
@@ -7801,7 +7801,7 @@ func SaveWorkflow(resp http.ResponseWriter, request *http.Request) {
78017801
if err != nil {
78027802
//log.Printf(string(body))
78037803
log.Printf("[ERROR] Failed workflow unmarshaling (save): %s", err)
7804-
resp.WriteHeader(401)
7804+
resp.WriteHeader(400)
78057805
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "%s"}`, err)))
78067806
return
78077807
}
@@ -8256,8 +8256,8 @@ func SaveWorkflow(resp http.ResponseWriter, request *http.Request) {
82568256
//workflow.ID = uuid.NewV4().String()
82578257

82588258
// Get the workflow and check if we own it
8259-
workflow, err := GetWorkflow(ctx, workflow.ID)
8260-
if err != nil || len(workflow.Actions) != 1 {
8259+
newWorkflow, err := GetWorkflow(ctx, workflow.ID)
8260+
if err != nil || len(newWorkflow.Actions) != 1 {
82618261
log.Printf("[ERROR] FAILED GETTING WORKFLOW: %s - CREATING NEW ID!", err)
82628262
workflow.ID = uuid.NewV4().String()
82638263
}
@@ -8282,6 +8282,8 @@ func SaveWorkflow(resp http.ResponseWriter, request *http.Request) {
82828282
//log.Printf("Setting actions")
82838283
actionFixing := []Action{}
82848284
appsAdded := []string{}
8285+
8286+
log.Printf("ACTIONS: %d", len(workflow.Actions))
82858287
for _, action := range workflow.Actions {
82868288
setAuthentication := false
82878289
if len(action.AuthenticationId) > 0 {
@@ -8302,8 +8304,6 @@ func SaveWorkflow(resp http.ResponseWriter, request *http.Request) {
83028304
// 1. Validate if auth for the app exists
83038305
// var appAuth AppAuthenticationStorage
83048306
setAuthentication = true
8305-
8306-
//App WorkflowApp `json:"app" datastore:"app,noindex"`
83078307
}
83088308

83098309
if setAuthentication {
@@ -8365,6 +8365,8 @@ func SaveWorkflow(resp http.ResponseWriter, request *http.Request) {
83658365
actionFixing = append(actionFixing, action)
83668366
}
83678367

8368+
log.Printf("ACTIONFIXING: %d", len(actionFixing))
8369+
83688370
newActions = actionFixing
83698371
} else {
83708372
log.Printf("FirstSave error: %s - %s", err, apperr)
@@ -8382,10 +8384,11 @@ func SaveWorkflow(resp http.ResponseWriter, request *http.Request) {
83828384
}
83838385
}
83848386

8385-
if len(newActions) > 0 {
8387+
if len(newActions) > 1 {
83868388
workflow.Actions = newActions
83878389
}
83888390

8391+
83898392
auth, authOk := request.URL.Query()["set_auth"]
83908393
if authOk && len(auth) > 0 && auth[0] == "true" {
83918394
for actionIndex, action := range workflow.Actions {
@@ -8538,6 +8541,7 @@ func SaveWorkflow(resp http.ResponseWriter, request *http.Request) {
85388541
}
85398542
}
85408543

8544+
85418545
err = SetWorkflow(ctx, workflow, workflow.ID)
85428546
if err != nil {
85438547
log.Printf("[ERROR] Failed saving workflow to database: %s", err)
@@ -13076,7 +13080,7 @@ func GetRequestIp(r *http.Request) string {
1307613080
// The client's IP is usually the first one.
1307713081
stringSplit := strings.Split(forwardedFor, ",")
1307813082
if len(stringSplit) > 1 {
13079-
log.Printf("[DEBUG] Found multiple IPs in X-Forwarded-For header: %s", forwardedFor)
13083+
log.Printf("[DEBUG] Found multiple IPs in X-Forwarded-For header: %s. Returning first.", forwardedFor)
1308013084
return stringSplit[0]
1308113085
} else {
1308213086
return forwardedFor
@@ -15612,7 +15616,6 @@ func ParsedExecutionResult(ctx context.Context, workflowExecution WorkflowExecut
1561215616
updateParentRan := false
1561315617

1561415618
if len(workflowExecution.Results) == len(workflowExecution.Workflow.Actions)+extraInputs {
15615-
//log.Printf("\nIN HERE WITH RESULTS %d vs %d\n", len(workflowExecution.Results), len(workflowExecution.Workflow.Actions)+extraInputs)
1561615619
finished := true
1561715620
lastResult := ""
1561815621

@@ -19404,14 +19407,6 @@ func HandleOpenId(resp http.ResponseWriter, request *http.Request) {
1940419407
}
1940519408
}
1940619409

19407-
//log.Printf("Got user body: %s", string(body))
19408-
19409-
/*
19410-
19411-
BELOW HERE ITS ALL COPY PASTE OF USER INFO THINGS!
19412-
19413-
*/
19414-
1941519410
if len(openidUser.Sub) == 0 && len(openidUser.Email) == 0 {
1941619411
log.Printf("[WARNING] No user found in openid login (2)")
1941719412
resp.WriteHeader(401)

0 commit comments

Comments
 (0)