Class: Spree::PermissionSets::UserManagement

Inherits:
Base
  • Object
show all
Defined in:
lib/spree/permission_sets/user_management.rb

Overview

Full permissions for user management.

This permission set grants full control over all user and related resources, including:

  • Users

  • Store credits

  • Roles

  • API keys

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Spree::PermissionSets::Base

Class Method Details

.categoryObject



20
21
22
# File 'lib/spree/permission_sets/user_management.rb', line 20

def category
  :user
end

.privilegeObject



16
17
18
# File 'lib/spree/permission_sets/user_management.rb', line 16

def privilege
  :management
end

Instance Method Details

#activate!Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/spree/permission_sets/user_management.rb', line 25

def activate!
  can [:admin, :read, :create, :update, :save_in_address_book, :remove_from_address_book, :addresses, :orders, :items], Spree.user_class

  # Note: This does not work with accessible_by.
  # See https://github.com/solidusio/solidus/pull/1263
  can :update_email, Spree.user_class do |user|
    user.spree_roles.none?
  end
  can :update_password, Spree.user_class do |user|
    user.spree_roles.none?
  end

  cannot :destroy, Spree.user_class
  can :manage, Spree::StoreCredit
  can :manage, :api_key
  can :read, Spree::Role
end