-
Notifications
You must be signed in to change notification settings - Fork 46
/
ability.rb
46 lines (35 loc) · 1.06 KB
/
ability.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
class Ability
include Hydra::Ability
include Hyrax::Ability
self.ability_logic += [:everyone_can_create_curation_concerns, :superadmin_permissions]
# Define any customized permissions here.
def custom_permissions
can [:create], Account
end
def admin_permissions
return unless admin?
super
can [:manage], [Site, Role, User]
restrict_site_admin_permissions unless current_user.has_role? :superadmin
end
def superadmin_permissions
return unless current_user.has_role? :superadmin
can :manage, :all
can :peek, Hyku::Application
end
def restrict_site_admin_permissions
# override curation_concerns admin roles to disable admin privileges on global models
cannot [:manage, :create, :discover, :show, :read, :edit, :update, :destroy], global_models
can [:read, :update], Account do |account|
account == Site.account
end
end
# Override admin? helper to use rolify roles
def admin?
current_user.has_role?(:admin, Site.instance)
end
private
def global_models
[Account]
end
end