deep_unrest 0.1.53 → 0.1.54
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/deep_unrest/read.rb +6 -3
- data/lib/deep_unrest/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: bf36ddb88a73244347e83a8a8b265b40d98e6f821a739e5c94435d329a38a5de
|
4
|
+
data.tar.gz: 9451ce3688642554c81b753efe7e2e2badd71d3be73d36398323c4a7c6171e91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ad246d65a81431253ddac7d9f3adb2bd975249402a2f7ed2d637c129a0d284ccf10b8dd7ac09bb5372908e21f560bc89b968803890441e7bf9f3c45286749be
|
7
|
+
data.tar.gz: 1b67db7bff81345c443824b74663953955d3c6e5f96a23894bcb82347b20f422aa48ed8a03823d5ceae3a3e39e71841ae5931fd78020e6050f9d9c19761feab4
|
data/lib/deep_unrest/read.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module DeepUnrest
|
4
4
|
module Read
|
5
|
-
def self.create_read_mappings(params, addr = [])
|
5
|
+
def self.create_read_mappings(params, user, addr = [])
|
6
6
|
return unless params
|
7
7
|
|
8
8
|
params.map do |k, v|
|
@@ -16,8 +16,9 @@ module DeepUnrest
|
|
16
16
|
addr: resource_addr,
|
17
17
|
key: k.camelize(:lower),
|
18
18
|
uuid: uuid,
|
19
|
+
current_user: user,
|
19
20
|
query: DeepUnrest.deep_underscore_keys(v) },
|
20
|
-
*create_read_mappings(v[:include], [*resource_addr, :include])]
|
21
|
+
*create_read_mappings(v[:include], user, [*resource_addr, :include])]
|
21
22
|
end.flatten.compact
|
22
23
|
end
|
23
24
|
|
@@ -64,6 +65,7 @@ module DeepUnrest
|
|
64
65
|
|
65
66
|
def self.query_item(mapping, mappings, parent_context, included, meta, addr, _parent)
|
66
67
|
query = resolve_conditions(mapping[:query].deep_dup, parent_context)
|
68
|
+
|
67
69
|
raise DeepUnrest::InvalidQuery unless query[:id] || query[:find]
|
68
70
|
|
69
71
|
if query.key?(:if)
|
@@ -124,6 +126,7 @@ module DeepUnrest
|
|
124
126
|
processor = JSONAPI::Processor.new(resource,
|
125
127
|
:find,
|
126
128
|
filters: query[:filter] || {},
|
129
|
+
context: { current_user: item[:current_user] },
|
127
130
|
sort_criteria: sort_criteria,
|
128
131
|
paginator: paginator)
|
129
132
|
|
@@ -195,7 +198,7 @@ module DeepUnrest
|
|
195
198
|
|
196
199
|
def self.read(ctx, params, user)
|
197
200
|
# create mappings for assembly / disassembly
|
198
|
-
mappings = create_read_mappings(params.to_unsafe_h)
|
201
|
+
mappings = create_read_mappings(params.to_unsafe_h, user)
|
199
202
|
|
200
203
|
# authorize user for requested scope(s)
|
201
204
|
DeepUnrest.authorization_strategy.authorize(mappings, user)
|
data/lib/deep_unrest/version.rb
CHANGED