Skip to content

Commit

Permalink
Fixes #21815 - Do not search for permissions when db is empty (thefor…
Browse files Browse the repository at this point in the history
  • Loading branch information
xprazak2 authored and ares committed Dec 14, 2017
1 parent 86b50aa commit 9e00543
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 1 deletion.
1 change: 1 addition & 0 deletions app/registries/foreman/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ def add_permissions_to_default_roles(args)
# Add plugin permissions to Manager and Viewer roles. Use this method if there are no special cases that need to be taken care of.
# Otherwise add_permissions_to_default_roles or add_resource_permissions_to_default_roles might be the methods you are looking for.
def add_all_permissions_to_default_roles
return if Foreman.in_rake?('db:migrate')
Plugin::RbacSupport.new.add_all_permissions_to_default_roles(Permission.where(:name => @rbac_registry.permission_names))
end

Expand Down
1 change: 0 additions & 1 deletion app/registries/foreman/plugin/rbac_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class RbacSupport
AUTO_EXTENDED_ROLES = [ Role::VIEWER, Role::MANAGER, Role::ORG_ADMIN ]

def add_all_permissions_to_default_roles(all_permissions)
return if Foreman.in_rake?('db:migrate')
view_permissions = all_permissions.where("name LIKE :name", :name => "view_%")
org_admin_permissions = all_permissions.where('resource_type <> :resource_type OR resource_type IS NULL', { :resource_type => "Organization" })
Role.transaction do
Expand Down

0 comments on commit 9e00543

Please sign in to comment.