petergate 1.3.0 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/petergate/action_controller/base.rb +12 -7
- 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: 1321402dd89f897c7b4fd9c32b5a6a375e6cccc8
|
4
|
+
data.tar.gz: 8b2bfc9840321e2e42ddf04ce2323bf103e3d686
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d72761ff90b4e08ef1678048aa608c505e17fc9ec365e112f3b64aa5072d35285219a0d4b7e730edeeb9fdff9785027c45a291eba7785a33eb8f284e46cd6ee0
|
7
|
+
data.tar.gz: 6ea6888d1818f492d2ab243edc5bfa45ecd88af3aa17cdff88208a99f4b3c565ddda239ba772b90137af8326c65f162b122b21c2bf5e43936b5a328d0c176314
|
@@ -34,11 +34,12 @@ module Petergate
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def controller_message
|
37
|
-
@_controller_message
|
37
|
+
@_controller_message || "Permission Denied"
|
38
38
|
end
|
39
39
|
|
40
40
|
def inherited(subclass)
|
41
41
|
subclass.instance_variable_set("@_controller_rules", instance_variable_get("@_controller_rules"))
|
42
|
+
subclass.instance_variable_set("@_controller_message", instance_variable_get("@_controller_message"))
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
@@ -76,11 +77,11 @@ module Petergate
|
|
76
77
|
v == :all ? self.class.all_actions : raise("No action for: #{v}")
|
77
78
|
when "Hash"
|
78
79
|
v[:except].present? ? self.class.except_actions(v[:except]) : raise("Invalid values for except: #{v.values}")
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
80
|
+
when "Array"
|
81
|
+
v
|
82
|
+
else
|
83
|
+
raise("No action for: #{v}")
|
84
|
+
end
|
84
85
|
|
85
86
|
h.merge({k => special_values})
|
86
87
|
end
|
@@ -101,12 +102,16 @@ module Petergate
|
|
101
102
|
current_user && (roles & current_user.roles).any?
|
102
103
|
end
|
103
104
|
|
105
|
+
def custom_message
|
106
|
+
defined?(self.class.controller_message) ? self.class.controller_message : 'Permission Denied'
|
107
|
+
end
|
108
|
+
|
104
109
|
def forbidden!(msg = nil)
|
105
110
|
respond_to do |format|
|
106
111
|
format.any(:js, :json, :xml) { render nothing: true, status: :forbidden }
|
107
112
|
format.html do
|
108
113
|
destination = current_user.present? ? request.referrer || after_sign_in_path_for(current_user) : root_path
|
109
|
-
redirect_to destination, notice: (msg ||
|
114
|
+
redirect_to destination, notice: (msg || custom_message)
|
110
115
|
end
|
111
116
|
end
|
112
117
|
end
|
data/lib/petergate/version.rb
CHANGED