haveapi 0.21.0 → 0.21.1

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
  SHA256:
3
- metadata.gz: 2b5848df30ec9ad0b4ce0539e09cbbb0f8ab46b3ddbd9ebe0c06fbafa08eb842
4
- data.tar.gz: 30218273467496ad5d42c275794de72dfc6a73c74e94022d5230adac64bcd4f6
3
+ metadata.gz: 0e72ad9fd9ee5a7d0ada6b5985e28f51d6fe65423b290aae824f6ff55a067145
4
+ data.tar.gz: c6c35096b29c02199c3dd4ae46d2ee8ec6920e2f5d5436596e4cde1a133c80cf
5
5
  SHA512:
6
- metadata.gz: 8cbf71233376763da8ef40eb176f15d0686b2417a502deb15c1a82efe3079177e31d4664cfebe6269c93abbe7e6f9446027ab1451a0232ddbc3379a0b79e7e5e
7
- data.tar.gz: 4871a061b0c3e85dc8bf1aef0fbedc37d91057281a35fcdae49727cf7ce80d9d318236fd5d231479df927576eb58deea52a82bf9ad8a3516531aae545f4fdd7b
6
+ metadata.gz: 722c8af5849aef6fe6dbbf48d53bb159c66a9dcd4decafcc4ba20a5f6fee441dbe0eb2d08a2f91283dd900869e1e36632281fcabc038a0ad8ed83dbc9255e053
7
+ data.tar.gz: b26b675cb2ce63c3d7f2723f3084bb7e7289d4ee896dfbdcf875ed841adedc9feb991b3ee76715586fc79d8b21657e537c446e2284aab24dd94361dfbbd78383
data/haveapi.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
 
17
17
  s.add_runtime_dependency 'activesupport', '>= 7.1'
18
18
  s.add_runtime_dependency 'github-markdown'
19
- s.add_runtime_dependency 'haveapi-client', '~> 0.21.0'
19
+ s.add_runtime_dependency 'haveapi-client', '~> 0.21.1'
20
20
  s.add_runtime_dependency 'json'
21
21
  s.add_runtime_dependency 'mail'
22
22
  s.add_runtime_dependency 'nesty', '~> 1.0'
@@ -214,6 +214,7 @@ module HaveAPI
214
214
 
215
215
  def describe(context)
216
216
  authorization = (@authorization && @authorization.clone) || Authorization.new
217
+ add_pre_authorize_blocks(authorization, context)
217
218
 
218
219
  if (context.endpoint || context.current_user) \
219
220
  && !authorization.authorized?(context.current_user, context.path_params_from_args)
@@ -281,6 +282,18 @@ module HaveAPI
281
282
  object.respond_to?(:id) ? object.id : nil
282
283
  end
283
284
  end
285
+
286
+ def add_pre_authorize_blocks(authorization, context)
287
+ ret = Action.call_hooks(
288
+ :pre_authorize,
289
+ args: [context],
290
+ initial: { blocks: [] }
291
+ )
292
+
293
+ ret[:blocks].reverse_each do |block|
294
+ authorization.prepend_block(block)
295
+ end
296
+ end
284
297
  end
285
298
 
286
299
  def initialize(request, version, params, body, context)
@@ -304,16 +317,7 @@ module HaveAPI
304
317
  Authorization.new {}
305
318
  end
306
319
 
307
- ret = call_class_hooks_as_for(
308
- Action,
309
- :pre_authorize,
310
- args: [@context],
311
- initial: { blocks: [] }
312
- )
313
-
314
- ret[:blocks].reverse_each do |block|
315
- @authorization.prepend_block(block)
316
- end
320
+ self.class.add_pre_authorize_blocks(@authorization, @context)
317
321
  end
318
322
 
319
323
  def validate!
@@ -4,6 +4,11 @@ module HaveAPI
4
4
  @blocks = [block]
5
5
  end
6
6
 
7
+ def initialize_clone(other)
8
+ super
9
+ @blocks = other.instance_variable_get('@blocks').clone
10
+ end
11
+
7
12
  # Returns true if user is authorized.
8
13
  # Block must call allow to authorize user, default rule is deny.
9
14
  def authorized?(user, path_params)
@@ -1,4 +1,4 @@
1
1
  module HaveAPI
2
2
  PROTOCOL_VERSION = '2.0'.freeze
3
- VERSION = '0.21.0'.freeze
3
+ VERSION = '0.21.1'.freeze
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haveapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.0
4
+ version: 0.21.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakub Skokan
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.21.0
47
+ version: 0.21.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.21.0
54
+ version: 0.21.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: json
57
57
  requirement: !ruby/object:Gem::Requirement