apiphobic-authorization 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae49ad16d7ccee68ad832094f557149dffe1b98c82975f31aba512b9f2cec00c
4
- data.tar.gz: 6ee28b1abc416e418e27db5d722f8f5d24fc255245f639cc0fc4925c539ff01b
3
+ metadata.gz: 936fbde0291882daeb50f81249a28d4c50a9762b659049c6495385703c61ab06
4
+ data.tar.gz: 65febd7701bada72341db5628e500983752376513720f44eb0cf6a9be4dab0cc
5
5
  SHA512:
6
- metadata.gz: 387c64f4a04f2028fd6ed326b5e855902388054589d7d56db872dad926d8d3506b2eba771704ba6563d3749978a9fd625420b3753aaa36ab5a9e020f00bfd2c5
7
- data.tar.gz: 2a60f92f107dbfcdc7d2bdb7008b2df9d0bf1fc63acea278116f923979e041a4ebea5ee41ecce6f6da5372f3322a5d559f6e15890471c56da75b541d6479d611
6
+ metadata.gz: 2de1a7afe900c518b888bd9f1231d76fcc47208450452c313e06767d259a3470a290d3acf869a6b2dd6c9c3f732f572f0bbed437320e44ecd01f827238c60971
7
+ data.tar.gz: 23afc8e9bd16eb52fe96b3e93122aef1decdf59e5bd12a8e50a67e1055a1a89c61d075e7781fc133509177d5cb9ac02d6738ab26484b1c76b875079e06a93d2d
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -37,19 +37,17 @@ class Scope
37
37
  end
38
38
 
39
39
  def call
40
- if scope_user_id
41
- user_scope
42
- else
40
+ if user.nil?
43
41
  public_scope
42
+ else
43
+ user_scope
44
44
  end
45
45
  end
46
46
 
47
47
  private
48
48
 
49
49
  def scope_user_id
50
- @scope_user_id ||= raw_parameters
51
- .fetch(:filter, {})
52
- .fetch(user_underscored_class_name, nil)
50
+ authorized_scope_id(name: user_underscored_class_name, default: user.id)
53
51
  end
54
52
 
55
53
  def user_underscored_class_name
@@ -59,6 +57,16 @@ class Scope
59
57
  base_user_class_name.underscore.downcase
60
58
  end
61
59
  end
60
+
61
+ def authorized_scope_id(name:, default:)
62
+ if token.admin?
63
+ raw_parameters
64
+ .fetch(:filter, {})
65
+ .fetch("#{name}_id", default)
66
+ else
67
+ default
68
+ end
69
+ end
62
70
  end
63
71
  end
64
72
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Apiphobic
4
4
  module Authorization
5
- VERSION = '1.2.0'
5
+ VERSION = '1.2.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apiphobic-authorization
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - thegranddesign
@@ -31,7 +31,7 @@ cert_chain:
31
31
  Y2GAoHKstmfIVhc4XHOPpmTd2o/C29O9oaRgjrkfQEhF/KvJ/PhoV5hvokzsCyI5
32
32
  iUeXPfvrGD/itYIBCgk+fnzyQQ4QtE5hTQaWQ3o2
33
33
  -----END CERTIFICATE-----
34
- date: 2018-05-03 00:00:00.000000000 Z
34
+ date: 2018-05-19 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: apiphobic-resource
metadata.gz.sig CHANGED
Binary file