Skip to content

Commit 692cfab

Browse files
committed
fix: edgecase where user wasn't able to save distributed workflows
1 parent 60e01b6 commit 692cfab

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

shared.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7731,9 +7731,25 @@ func SaveWorkflow(resp http.ResponseWriter, request *http.Request) {
77317731
log.Printf("[AUDIT] Letting verified support admin %s access workflow %s (save workflow)", user.Username, workflow.ID)
77327732

77337733
workflow.ID = tmpworkflow.ID
7734+
77347735
} else if tmpworkflow.OrgId == user.ActiveOrg.Id && user.Role != "org-reader" {
77357736
log.Printf("[AUDIT] User %s is accessing workflow %s (save workflow)", user.Username, tmpworkflow.ID)
77367737
workflow.ID = tmpworkflow.ID
7738+
} else if ArrayContains(user.Orgs, tmpworkflow.OrgId) {
7739+
tmpWorkflowOrg, err := GetOrg(ctx, tmpworkflow.OrgId)
7740+
if err != nil {
7741+
log.Printf("[WARNING] Failed getting org for workflow %s: %s", tmpworkflow.OrgId, err)
7742+
resp.WriteHeader(401)
7743+
resp.Write([]byte(`{"success": false}`))
7744+
return
7745+
}
7746+
7747+
for _, User := range tmpWorkflowOrg.Users {
7748+
if user.Id == User.Id && User.Role != "org-reader" {
7749+
log.Printf("[AUDIT] (1) User %s is accessing workflow %s (save workflow)", user.Username, tmpworkflow.ID)
7750+
workflow.ID = tmpworkflow.ID
7751+
}
7752+
}
77377753
} else {
77387754
log.Printf("[AUDIT] Wrong user (%s) for workflow %s (save)", user.Username, tmpworkflow.ID)
77397755
resp.WriteHeader(401)

0 commit comments

Comments
 (0)