plutonium 0.15.3 → 0.15.4
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/app/views/components/sidebar_menu/sidebar_menu_component.rb +1 -1
- data/lib/plutonium/core/controllers/authorizable.rb +5 -0
- data/lib/plutonium/core/controllers/entity_scoping.rb +4 -4
- data/lib/plutonium/resource/controller.rb +14 -4
- data/lib/plutonium/resource/controllers/authorizable.rb +1 -1
- data/lib/plutonium/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69be8d5055a10969befe7de4c78dea74e60f1da9ed5c3754d7a0b70ad74e6974
|
4
|
+
data.tar.gz: 98c4fb79a936ab08f6164c13bcd268f9ecaa4de42fc7ce1be5b47d68fe33a2d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: faa4d002ac3d47973decd9531931131407b64de718acf1914ac3f8fa2ca1d584a562940897a4dff20591c94804b029ea001a88af66e0acde61e1dbe58e68a995
|
7
|
+
data.tar.gz: b91536d180e95b9d80e95fca3064e788bfca9410da7bd4e003c6fc7a618f7a3e9d7298ac38f7a8453f55e40776b5d6faae6560a9110eb04b8a1b265a74492ddb
|
@@ -28,6 +28,11 @@ module Plutonium
|
|
28
28
|
def entity_scope_for_authorize
|
29
29
|
scoped_to_entity? ? current_scoped_entity : nil
|
30
30
|
end
|
31
|
+
|
32
|
+
def verify_authorized
|
33
|
+
# we don't use action policy's inbuilt checks, so ensure they are neutered,
|
34
|
+
# also ensures pundit checks are disabled.
|
35
|
+
end
|
31
36
|
end
|
32
37
|
end
|
33
38
|
end
|
@@ -81,16 +81,16 @@ module Plutonium
|
|
81
81
|
# @return [ActiveRecord::Base, nil] the current scoped entity or nil if not found
|
82
82
|
# @raise [NotImplementedError] if the scoping strategy is unknown
|
83
83
|
def fetch_current_scoped_entity
|
84
|
-
|
84
|
+
case scoped_entity_strategy
|
85
85
|
when :path
|
86
|
-
fetch_entity_from_path
|
86
|
+
scoped_entity = fetch_entity_from_path
|
87
|
+
authorize! scoped_entity, to: :read?
|
88
|
+
scoped_entity
|
87
89
|
when Symbol
|
88
90
|
send(scoped_entity_strategy)
|
89
91
|
else
|
90
92
|
raise NotImplementedError, "Unknown scoped entity strategy: #{scoped_entity_strategy.inspect}"
|
91
93
|
end
|
92
|
-
authorize! scoped_entity, to: :read?
|
93
|
-
scoped_entity
|
94
94
|
end
|
95
95
|
|
96
96
|
# Fetches the scoped entity from the path parameters.
|
@@ -172,8 +172,13 @@ module Plutonium
|
|
172
172
|
# @param [Hash] input_params The input parameters
|
173
173
|
def override_entity_scoping_params(input_params)
|
174
174
|
if scoped_to_entity?
|
175
|
-
input_params
|
176
|
-
|
175
|
+
if input_params.key?(scoped_entity_param_key) || resource_class.method_defined?(:"#{scoped_entity_param_key}=")
|
176
|
+
input_params[scoped_entity_param_key] = current_scoped_entity
|
177
|
+
end
|
178
|
+
|
179
|
+
if input_params.key?(:"#{scoped_entity_param_key}_id") || resource_class.method_defined?(:"#{scoped_entity_param_key}_id=")
|
180
|
+
input_params[:"#{scoped_entity_param_key}_id"] = current_scoped_entity.id
|
181
|
+
end
|
177
182
|
end
|
178
183
|
end
|
179
184
|
|
@@ -181,8 +186,13 @@ module Plutonium
|
|
181
186
|
# @param [Hash] input_params The input parameters
|
182
187
|
def override_parent_params(input_params)
|
183
188
|
if current_parent.present?
|
184
|
-
input_params
|
185
|
-
|
189
|
+
if input_params.key?(parent_input_param) || resource_class.method_defined?(:"#{parent_input_param}=")
|
190
|
+
input_params[parent_input_param] = current_parent
|
191
|
+
end
|
192
|
+
|
193
|
+
if input_params.key?(:"#{parent_input_param}_id") || resource_class.method_defined?(:"#{parent_input_param}_id=")
|
194
|
+
input_params[:"#{parent_input_param}_id"] = current_parent.id
|
195
|
+
end
|
186
196
|
end
|
187
197
|
end
|
188
198
|
|
@@ -77,7 +77,7 @@ module Plutonium
|
|
77
77
|
#
|
78
78
|
# @raise [ActionMissingCurrentAuthorizedScope] if current_authorized_scope hasn't been called
|
79
79
|
def verify_current_authorized_scope
|
80
|
-
return if
|
80
|
+
return if verify_current_authorized_scope_skipped
|
81
81
|
return if current_authorized_scope_count > 0
|
82
82
|
|
83
83
|
raise ActionMissingCurrentAuthorizedScope.new(controller_path, action_name)
|
data/lib/plutonium/version.rb
CHANGED