Skip to content

Commit

Permalink
Merge pull request #2428 from actiontech/hangyan
Browse files Browse the repository at this point in the history
chore:When there is no matching user, the person to be operated is al…
  • Loading branch information
ColdWaterLW authored May 22, 2024
2 parents 7c60cd1 + a3714d9 commit 0fc7558
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sqle/model/project_permission.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ AND (w.create_user_id = ? OR cur_ass_user.id = ? OR op_ass_user.id = ?)
return count > 0, nil
}

// GetCanAuditWorkflowUsers will return admin user if no qualified user is found, preventing the process from being stuck because no user can operate
// GetCanAuditWorkflowUsers will return supper admin and project admin user if no qualified user is found, preventing the process from being stuck because no user can operate
func (s *Storage) GetCanAuditWorkflowUsers(instance *Instance) (users []*User, err error) {
users, err = s.GetWithOperationUserFromInstance(instance, OP_WORKFLOW_AUDIT)
if err != nil {
Expand All @@ -333,10 +333,10 @@ func (s *Storage) GetCanAuditWorkflowUsers(instance *Instance) (users []*User, e
if len(users) != 0 {
return
}
return s.GetUsersByNames([]string{DefaultAdminUser})
return s.GetManageUsersByProjectID(instance.ProjectId)
}

// GetCanExecuteWorkflowUsers will return admin user if no qualified user is found, preventing the process from being stuck because no user can operate
// GetCanExecuteWorkflowUsers will return supper admin and project admin if no qualified user is found, preventing the process from being stuck because no user can operate
func (s *Storage) GetCanExecuteWorkflowUsers(instance *Instance) (users []*User, err error) {
users, err = s.GetWithOperationUserFromInstance(instance, OP_WORKFLOW_EXECUTE)
if err != nil {
Expand All @@ -345,7 +345,7 @@ func (s *Storage) GetCanExecuteWorkflowUsers(instance *Instance) (users []*User,
if len(users) != 0 {
return
}
return s.GetUsersByNames([]string{DefaultAdminUser})
return s.GetManageUsersByProjectID(instance.ProjectId)
}

/*
Expand Down
10 changes: 10 additions & 0 deletions sqle/model/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,13 @@ func GetOverlapOfUsers(users1, users2 []*User) []*User {
}
return res
}

func (s *Storage) GetManageUsersByProjectID(projectID uint) ([]*User, error) {
var users []*User
err := s.db.Model(&User{}).
Joins("LEFT JOIN project_manager pm ON pm.user_id = users.id").
Where("pm.project_id = ?", projectID).
Where("users.deleted_at IS NULL").
Find(&users).Error
return users, errors.ConnectStorageErrWrapper(err)
}

0 comments on commit 0fc7558

Please sign in to comment.