Skip to content

Commit

Permalink
remove storage.GetInstanceIdsByWorkflowID, remove dms.GetInstanceIdNa…
Browse files Browse the repository at this point in the history
…meMapByIds
  • Loading branch information
rocky114 committed Nov 7, 2023
1 parent 8e7b98e commit 31c1594
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
14 changes: 2 additions & 12 deletions sqle/api/controller/v1/project_permission.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,8 @@ func CheckCurrentUserCanOperateWorkflow(c echo.Context, projectUid string, workf
}

if len(ops) > 0 {
instanceIds, err := s.GetInstanceIdsByWorkflowID(workflow.WorkflowId)
if err != nil {
return err
}

instances, err := dms.GetInstancesInProjectByIds(c.Request().Context(), string(workflow.ProjectId), instanceIds)
if err != nil {
return err
}

for _, instance := range instances {
if !up.CanOpInstanceNoAdmin(instance.GetIDStr(), ops...) {
for _, item := range workflow.Record.InstanceRecords {
if !up.CanOpInstanceNoAdmin(item.Instance.GetIDStr(), ops...) {
return ErrWorkflowNoAccess
}
}
Expand Down
13 changes: 2 additions & 11 deletions sqle/server/workflow_schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,17 +367,8 @@ func CheckCurrentUserCanOperateWorkflowByUser(user *model.User, projectUid strin
return nil
}
if len(ops) > 0 {
instanceIds, err := s.GetInstanceIdsByWorkflowID(workflow.WorkflowId)
if err != nil {
return err
}

instances, err := dms.GetInstancesInProjectByIds(context.TODO(), string(workflow.ProjectId), instanceIds)
if err != nil {
return err
}
for _, instance := range instances {
if !up.CanOpInstanceNoAdmin(instance.GetIDStr(), ops...) {
for _, item := range workflow.Record.InstanceRecords {
if !up.CanOpInstanceNoAdmin(item.Instance.GetIDStr(), ops...) {
return ErrWorkflowNoAccess
}
}
Expand Down

0 comments on commit 31c1594

Please sign in to comment.