plugins/identity/app/services/service_layer/identity_services/user.rb
# Returns assigned users for the given scope and role (e.g.
# project_id: PROJECT_ID, domain_id: DOMAIN_ID, role: ROLE)
# This method looks recursively for assigned users of project,
# parent_projects and domain.
Returns assigned users for the given scope and role
This method looks recursively for assigned users of project,
parent_projects and domain.
Returns assigned users for the given scope and role This method looks recursively for assigned users of project parent_projects and domain .
def list_scope_assigned_users(options = {})
        admins = []
        project_id = options[:project_id]
        domain_id = options[:domain_id]
        role = options[:role]
        raise_error = options[:raise_error]
        return admins if role.nil?
        begin
          if project_id 
            ras = role_assignments(
              'scope.project.id' => project_id, 'role.id' => role.id,
              effective: true, include_subtree: true
            )
            admins.concat(role_assignments_to_users(ras))
            if admins.length.zero? 
              project = find_project(project_id)
              if project
                admins = list_scope_assigned_users(
                  project_id: project.parent_id, role: role
                )
              end
            end
          elsif domain_id 
            ras = role_assignments('scope.domain.id' => domain_id,
                                   'role.id' => role.id, effective: true)
            admins.concat(role_assignments_to_users(ras))
          end
        rescue => e
          raise e if raise_error
        end
        admins.delete_if { |a| a.id.nil? } 
      end
def list_scope_assigned_users ( options = { } ) admins = [ ] project_id = options [ :project_id ] domain_id = options [ :domain_id ] role = options [ :role ] raise_error = options [ :raise_error ] return admins if role . nil? begin if project_id ras = role_assignments ( 'scope.project.id' => project_id , 'role.id' => role . id , effective : true , include_subtree : true ) admins . concat ( role_assignments_to_users ( ras ) ) if admins . length . zero? project = find_project ( project_id ) if project admins = list_scope_assigned_users ( project_id : project . parent_id , role : role ) end end elsif domain_id ras = role_assignments ( 'scope.domain.id' => domain_id , 'role.id' => role . id , effective : true ) admins . concat ( role_assignments_to_users ( ras ) ) end rescue => e raise e if raise_error end admins . delete_if { | a | a . id . nil? } end
Returns assigned users for the given scope and role (e.g.
Returns assigned users for the given scope and role ( e . g .
# do nothing if role is nil # project_id is presented # get role_assignments for this project_id # load users (not very performant but there is no other option # to get users by ids) # no admins for this project_id found # load project # try to get admins recursively by parent_id # project_id is nil but domain_id is presented # get role_assignments for this domain_id # load users # delete crap
options
<not_specific>