1 |
class UserPolicy < AuthenticatedPolicy |
× |
2 |
|
× |
3 |
class Scope < ApplicationPolicy::Scope |
× |
4 |
def resolve |
× |
5 |
if user
|
× |
6 |
scope.all |
× |
7 |
else
|
× |
8 |
scope.none |
× |
9 |
end
|
× |
10 |
end
|
× |
11 |
end
|
× |
12 |
|
× |
13 |
def index? |
× |
14 |
true
|
× |
15 |
end
|
× |
16 |
|
× |
17 |
def manage? |
× |
18 |
user.is_admin? and ( (record == User || record.id != 0 && !record.has_role?(:superadmin)) || user.has_role?(:superadmin) ) |
× |
19 |
end
|
× |
20 |
|
× |
21 |
def inspect? |
× |
22 |
user.is_staff? |
× |
23 |
end
|
× |
24 |
|
× |
25 |
def show? |
× |
26 |
scope.where(:id => record.id).exists?
|
× |
27 |
end
|
× |
28 |
|
× |
29 |
def create? |
× |
30 |
false
|
× |
31 |
end
|
× |
32 |
|
× |
33 |
def su? |
× |
34 |
user.is_admin? and ( (record == User || record.id != 0 && !record.is_admin?) || user.has_role?(:superadmin) ) |
× |
35 |
end
|
× |
36 |
|
× |
37 |
def add_brownie? |
× |
38 |
user.is_staff? |
× |
39 |
end
|
× |
40 |
|
× |
41 |
def email? |
× |
42 |
user.is_admin? |
× |
43 |
end
|
× |
44 |
end
|
× |
45 |
|
× |