jsonapi-authorization 1.0.0.alpha4 → 1.0.0.alpha5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38df18640b26a88119c4c253745a5b78bf549f16
|
4
|
+
data.tar.gz: 1e3676e726ba546d80ed364d1a16673a2c78ebd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41b360cfcee0708244121f9b1debea24e1414776c89346b7ede2e57c0b2e1178a0587f39a838ca8b2641e555c529cbbdc0f9505467aa30dfd022bc62f1a07422
|
7
|
+
data.tar.gz: c0ba742a117a18b2273ed7662187d70a65e404f3c09b1bb48e37801ebbe7396ba39dd1348508e6ecee7b0a14dfd7ddbd1639f7e73afcbab7b84ca2d1f5bb974a
|
@@ -237,10 +237,15 @@ module JSONAPI
|
|
237
237
|
|
238
238
|
private
|
239
239
|
|
240
|
-
def authorize_relationship_operation(
|
240
|
+
def authorize_relationship_operation(
|
241
|
+
source_record,
|
242
|
+
relationship_method,
|
243
|
+
related_record_or_records = nil
|
244
|
+
)
|
241
245
|
policy = ::Pundit.policy(user, source_record)
|
242
246
|
if policy.respond_to?(relationship_method)
|
243
|
-
|
247
|
+
args = [relationship_method, related_record_or_records].reject(&:nil?)
|
248
|
+
unless policy.public_send(*args)
|
244
249
|
raise ::Pundit::NotAuthorizedError,
|
245
250
|
query: relationship_method,
|
246
251
|
record: source_record,
|
@@ -248,6 +253,11 @@ module JSONAPI
|
|
248
253
|
end
|
249
254
|
else
|
250
255
|
::Pundit.authorize(user, source_record, 'update?')
|
256
|
+
if related_record_or_records
|
257
|
+
Array(related_record_or_records).each do |related_record|
|
258
|
+
::Pundit.authorize(user, related_record, 'update?')
|
259
|
+
end
|
260
|
+
end
|
251
261
|
end
|
252
262
|
end
|
253
263
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonapi-authorization
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.alpha5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vesa Laakso
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-06-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jsonapi-resources
|