Skip to content

Commit

Permalink
Add permission set for managing User Roles
Browse files Browse the repository at this point in the history
This permission set enables the user to manage roles and read users.
  • Loading branch information
the-krg committed Aug 25, 2023
1 parent 227f43c commit 1e85606
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/lib/spree/permission_sets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
require 'spree/permission_sets/promotion_management'
require 'spree/permission_sets/restricted_stock_display'
require 'spree/permission_sets/restricted_stock_management'
require 'spree/permission_sets/role_management'
require 'spree/permission_sets/stock_display'
require 'spree/permission_sets/stock_management'
require 'spree/permission_sets/super_user'
Expand Down
15 changes: 15 additions & 0 deletions core/lib/spree/permission_sets/role_management.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

module Spree
module PermissionSets
# Permissions for viewing and editing the user roles.
#
# This permission set allows full control over roles, but only allows reading users.
class RoleManagement < PermissionSets::Base
def activate!
can [:read, :admin, :edit, :addresses, :orders, :items], Spree.user_class
can :manage, Spree::Role
end
end
end
end
2 changes: 1 addition & 1 deletion core/lib/spree/permission_sets/user_display.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class UserDisplay < PermissionSets::Base
def activate!
can [:read, :admin, :edit, :addresses, :orders, :items], Spree.user_class
can [:read, :admin], Spree::StoreCredit
can :read, Spree::Role
can [:read, :admin], Spree::Role
end
end
end
Expand Down

0 comments on commit 1e85606

Please sign in to comment.