api-blocks 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/api_blocks/controller.rb +7 -5
- data/lib/api_blocks/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: 71a94ae91f91b668d8be3d5b5317a9d72124e86e67fc1dd9f3d644a2325ca53e
|
4
|
+
data.tar.gz: 575a294250ee9c73f16d17d3c8d571af360cde384af11761dadc740d17ba45c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f98d59370e11d0a66db46e6cc202a0027530071f6a70e2636605fd18dc59789a695835885d3f412ff74a0a79f35d540e7938189fc2b301d9df834687190d65a0
|
7
|
+
data.tar.gz: 7d4afc732ad1bf08f5bf6694a66d49284e146f7e30c7e79cf81502f7570d3129a28c6ecd576b56f8df035e0815bf47ae6a06f88b369feaf22a45e3af0ca6f7fb
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
# frozen_string_litreal: true
|
4
2
|
|
5
3
|
require 'pundit'
|
@@ -37,20 +35,24 @@ module ApiBlocks::Controller
|
|
37
35
|
# Override policy_scope to lookup pundit policies under the `scope`
|
38
36
|
# namespace
|
39
37
|
def policy_scope(scope)
|
40
|
-
|
38
|
+
api_scope = self.class.pundit_api_scope || []
|
39
|
+
|
40
|
+
super(api_scope + [scope])
|
41
41
|
end
|
42
42
|
|
43
43
|
# Override authorize to lookup pundit policies under the `scope`
|
44
44
|
# namespace
|
45
45
|
def authorize(record, query = nil)
|
46
|
-
|
46
|
+
api_scope = self.class.pundit_api_scope || []
|
47
|
+
|
48
|
+
super(api_scope + [record], query)
|
47
49
|
end
|
48
50
|
|
49
51
|
handle_api_error Pundit::NotAuthorizedError do |error|
|
50
52
|
[{ detail: error.message }, :forbidden]
|
51
53
|
end
|
52
54
|
|
53
|
-
|
55
|
+
thread_mattr_accessor :pundit_api_scope
|
54
56
|
end
|
55
57
|
|
56
58
|
class_methods do
|
data/lib/api_blocks/version.rb
CHANGED