Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly shortcut "everything" for privileges #17526

Merged
merged 1 commit into from
Jun 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions app/models/miq_user_role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def feature_identifiers
# @param identifier [String] Product feature identifier to check if this role allows access to it
# Returns true when requested feature is directly assigned or a descendant of a feature
def allows?(identifier:)
if feature_identifiers.include?(identifier)
# all features are children of "everything", so checking it isn't strictly necessary
# but it simplifies testing
if feature_identifiers.include?(MiqProductFeature::SUPER_ADMIN_FEATURE) || feature_identifiers.include?(identifier)
true
elsif (parent_identifier = MiqProductFeature.feature_parent(identifier))
allows?(:identifier => parent_identifier)
Expand Down Expand Up @@ -107,13 +109,13 @@ def super_admin_user?
end

def report_admin_user?
allows_any?(:identifiers => [MiqProductFeature::SUPER_ADMIN_FEATURE, MiqProductFeature::REPORT_ADMIN_FEATURE])
allows?(:identifier => MiqProductFeature::REPORT_ADMIN_FEATURE)
end

alias admin_user? report_admin_user?

def request_admin_user?
allows_any?(:identifiers => [MiqProductFeature::SUPER_ADMIN_FEATURE, MiqProductFeature::REQUEST_ADMIN_FEATURE])
allows?(:identifier => MiqProductFeature::REQUEST_ADMIN_FEATURE)
end

def self.default_tenant_role
Expand Down