bsm-rails-api 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bsm/rails_api.rb +2 -0
- data/lib/bsm/rails_api/authorization.rb +6 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 732b21fdc3472d8d5f910950590adfd64060776d
|
4
|
+
data.tar.gz: 909dd536083ed3e566dd38e398c804991214618f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7723109485f1ace328add3c0da5ff08e64b9f60fc4b0f601d639cc1d0e1f98a1186f05d71d6b934289620de5bcb1c69509b34b9aeb9214f957507b34151cf070
|
7
|
+
data.tar.gz: 6c7251612573ffdb4e0aab872bd9c2ade5815f24872ec56a67f798b2589c78d02c6b7a47cf52af4954fe4077b0b166dec8c624162f3e204ccfcd1bc98be55080
|
data/lib/bsm/rails_api.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'active_support/concern'
|
2
|
-
|
3
1
|
module BSM::RailsAPI::Authorization
|
4
2
|
extend ActiveSupport::Concern
|
5
3
|
|
@@ -36,11 +34,12 @@ module BSM::RailsAPI::Authorization
|
|
36
34
|
end.flatten.uniq
|
37
35
|
|
38
36
|
before_action only: acts do |ctrl|
|
39
|
-
user = ctrl.send(:current_user)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
37
|
+
if user = ctrl.send(:current_user)
|
38
|
+
reqs = opts[user.kind.to_sym]
|
39
|
+
ctrl.send :unauthorized! if reqs != :all && (Array.wrap(reqs) & user.roles).empty?
|
40
|
+
else
|
41
|
+
ctrl.send :unauthorized!
|
42
|
+
end
|
44
43
|
ctrl.send :instance_variable_set, :@_bsm_rails_api_authorized, true
|
45
44
|
end unless acts.empty?
|
46
45
|
end
|