Skip to content

Commit

Permalink
Load roles from database to RoleConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
the-krg committed Aug 25, 2023
1 parent 1e85606 commit b74d831
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/app/models/spree/role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Role < Spree::Base
has_many :permission_sets, through: :role_permissions
has_many :users, through: :role_users

scope :non_base_roles, -> { where.not(name: ['admin']) }
scope :non_base_roles, -> { where.not(name: ['admin', 'default']) }

validates_uniqueness_of :name, case_sensitive: true
validates :name, uniqueness: true
Expand Down
4 changes: 4 additions & 0 deletions core/lib/spree/app_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,10 @@ def roles
@roles ||= Spree::RoleConfiguration.new.tap do |roles|
roles.assign_permissions :default, ['Spree::PermissionSets::DefaultCustomer']
roles.assign_permissions :admin, ['Spree::PermissionSets::SuperUser']

Spree::Role.non_base_roles.each do |role|
roles.assign_permissions role.name, role.permission_sets_constantized
end
end
end

Expand Down

0 comments on commit b74d831

Please sign in to comment.