action_policy 0.7.0 → 0.7.2

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: 0e9a1595099a6b87f22ec08fbd6676cd73cea94672c8cc9276525e82e9ba8c1a
4
- data.tar.gz: bc743bbc45679d6583d3549cad77fc37f4004d051ef54d4cf8baa252730b0621
3
+ metadata.gz: 5c3b8d128bdf4e37224446e7c5a65698327a927c743e99757cf6f5363db93ff5
4
+ data.tar.gz: f046c13d93cff63aa06fd15f4d6375a8498c04d0637110df0ff86891a206fb84
5
5
  SHA512:
6
- metadata.gz: cf8db058edbeb5b198fb58f8ccab0d35e1f71aeb7891a6bab93bf6e04b9819fc321706bfbbe6437b58021325f01f62d5e891e812690a80f8464ef2c825ef8e47
7
- data.tar.gz: 8aceb6e4a30d97e487b7bb29de4393c3c7f8598261c12f36dd66743d2a3c469bce61423c062e38b757d5265711d07172a743d04060dc336521f2dd10f80b7693
6
+ metadata.gz: b66f496343688a55907070ba6b6e82e24a5d358934d6809e1577e80f2c67a81342fe449cbf46942c1e8ff064f79ae898235efa32b63e9fc402e5b416bc223efc
7
+ data.tar.gz: 57088a306e642a0dd22a68c4da019dbd8669e7fa63ec1e99fb7bb819a563ca514be2200c669486d40f5a4b152a325ee0adc3abcaa6187b45c1f0ef37ddcb7a86
data/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.7.2 (2024-11-21)
6
+
7
+ - Fix missing details in deny! message interpolation. ([@palkan][])
8
+
9
+ - Fix implicit authorization target in anonymous controllers. ([@palkan][])
10
+
11
+ - Improve default `ActionPolicy::Unauthorized` error message. ([@Spone][])
12
+
13
+ Before: `Not Authorized` / After: `Not authorized: UserPolicy#create? returns false`
14
+
15
+ ## 0.7.1 (2024-07-25)
16
+
17
+ - Support passing scope options to callable scope objects. ([@palkan][])
18
+
5
19
  ## 0.7.0 (2024-06-20)
6
20
 
7
21
  - **Ruby 2.7+** is required.
@@ -520,3 +534,4 @@ This value is now stored in a cache (if any) instead of just the call result (`t
520
534
  [@tomdalling]: https://github.com/tomdalling
521
535
  [@matsales28]: https://github.com/matsales28
522
536
  [@killondark]: https://github.com/killondark
537
+ [@Spone]: https://github.com/Spone
@@ -220,7 +220,7 @@ module ActionPolicy
220
220
  end
221
221
 
222
222
  def deny!(reason = nil)
223
- result&.reasons&.add(self, reason) if reason
223
+ result&.reasons&.add(self, reason, result.details) if reason
224
224
  super()
225
225
  end
226
226
  end
@@ -10,7 +10,7 @@ module ActionPolicy
10
10
  @rule = rule
11
11
  @result = policy.result
12
12
 
13
- super("Not Authorized")
13
+ super("Not authorized: #{@policy}##{@rule} returns false")
14
14
  end
15
15
  end
16
16
 
@@ -220,7 +220,7 @@ module ActionPolicy
220
220
  end
221
221
 
222
222
  def deny!(reason = nil)
223
- result&.reasons&.add(self, reason) if reason
223
+ result&.reasons&.add(self, reason, result.details) if reason
224
224
  super()
225
225
  end
226
226
  end
@@ -117,7 +117,7 @@ module ActionPolicy
117
117
  name, callable = prepare_args(name, callable)
118
118
 
119
119
  mid = :"__scoping__#{type}__#{name}"
120
- block = ->(target) { callable.call(self, target) } if callable
120
+ block = ->(target, **opts) { callable.call(self, target, **opts) } if callable
121
121
 
122
122
  define_method(mid, &block)
123
123
 
@@ -56,7 +56,7 @@ module ActionPolicy
56
56
  # Tries to infer the resource class from controller name
57
57
  # (i.e. `controller_name.classify.safe_constantize`).
58
58
  def implicit_authorization_target
59
- controller_name.classify.safe_constantize
59
+ controller_name&.classify&.safe_constantize
60
60
  end
61
61
 
62
62
  def verify_authorized
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActionPolicy
4
- VERSION = "0.7.0"
4
+ VERSION = "0.7.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_policy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-20 00:00:00.000000000 Z
11
+ date: 2024-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-next-core