petergate 1.2.6 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/petergate/action_controller/base.rb +8 -4
- data/lib/petergate/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8be82833c7259e85ee80f35a935c7762a80bb9d2
|
4
|
+
data.tar.gz: f45cce812bbdc12d63a317a1759e5fd013c73add
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b18da7bf7fc915bc1b67e3f7602c58a6e45cddfc3b1f53753036839f08ca3ec9546ead0ad5166c3c0a02f442df98dabd57f72daa1930a552a196db046871736f
|
7
|
+
data.tar.gz: ad2529c9ed5c8b84b50874fcd2e0d2d3b8de58d7675239fd1e693d92e463f97516958b63cdaf1f55ad63e552f3b83ad79fca18a3e5567076b041d40f57f1284c
|
@@ -27,11 +27,16 @@ module Petergate
|
|
27
27
|
|
28
28
|
instance_eval do
|
29
29
|
@_controller_rules = rules
|
30
|
+
@_controller_message = rules.delete(:message)
|
30
31
|
|
31
32
|
def controller_rules
|
32
33
|
@_controller_rules
|
33
34
|
end
|
34
35
|
|
36
|
+
def controller_message
|
37
|
+
@_controller_message
|
38
|
+
end
|
39
|
+
|
35
40
|
def inherited(subclass)
|
36
41
|
subclass.instance_variable_set("@_controller_rules", instance_variable_get("@_controller_rules"))
|
37
42
|
end
|
@@ -53,7 +58,7 @@ module Petergate
|
|
53
58
|
base.before_filter do
|
54
59
|
unless logged_in?(:admin)
|
55
60
|
message= defined?(check_access) ? check_access : true
|
56
|
-
if message.is_a?(String)
|
61
|
+
if message == false || message.is_a?(String)
|
57
62
|
if user_signed_in?
|
58
63
|
forbidden! message
|
59
64
|
else
|
@@ -84,13 +89,12 @@ module Petergate
|
|
84
89
|
end
|
85
90
|
|
86
91
|
def permissions(rules = {all: [:index, :show], customer: [], wiring: []})
|
87
|
-
message = rules.delete(:message)
|
88
92
|
rules = parse_permission_rules(rules)
|
89
93
|
allowances = [rules[:all]]
|
90
94
|
current_user.roles.each do |role|
|
91
95
|
allowances << rules[role]
|
92
96
|
end if logged_in?(:user)
|
93
|
-
allowances.flatten.compact.include?(params[:action].to_sym)
|
97
|
+
allowances.flatten.compact.include?(params[:action].to_sym)
|
94
98
|
end
|
95
99
|
|
96
100
|
def logged_in?(*roles)
|
@@ -102,7 +106,7 @@ module Petergate
|
|
102
106
|
format.any(:js, :json, :xml) { render nothing: true, status: :forbidden }
|
103
107
|
format.html do
|
104
108
|
destination = current_user.present? ? request.referrer || after_sign_in_path_for(current_user) : root_path
|
105
|
-
redirect_to destination, notice: (msg || 'Permission Denied')
|
109
|
+
redirect_to destination, notice: (msg || self.class.controller_message || 'Permission Denied')
|
106
110
|
end
|
107
111
|
end
|
108
112
|
end
|
data/lib/petergate/version.rb
CHANGED