action_policy 0.7.1 → 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: 9a2cec9201751bbc94bfa0875d8b4ed69500cdeea4ab4a1d9717a1786b3adba8
4
- data.tar.gz: 4b0be37589400d6491bf4e7b5c7a6e2e46b5e71629f9c6b93d28c59f58b0d4ec
3
+ metadata.gz: 5c3b8d128bdf4e37224446e7c5a65698327a927c743e99757cf6f5363db93ff5
4
+ data.tar.gz: f046c13d93cff63aa06fd15f4d6375a8498c04d0637110df0ff86891a206fb84
5
5
  SHA512:
6
- metadata.gz: 3751003181c14a8f2f71889525597d7b53cd2553cc52e955bbd668891f27ae34ec684fce36b1118b57c1527f78cdf6dca98b90b1dec7efc6cd20e59dc9f18fde
7
- data.tar.gz: c6d0b96504ac2f70264b12df798cbbf4fc953b139666522e5dad8b6b3c5fd8702d522d21ed35c6023443b9ba9872720499931b3996e64e3d5652b600eb23e2a0
6
+ metadata.gz: b66f496343688a55907070ba6b6e82e24a5d358934d6809e1577e80f2c67a81342fe449cbf46942c1e8ff064f79ae898235efa32b63e9fc402e5b416bc223efc
7
+ data.tar.gz: 57088a306e642a0dd22a68c4da019dbd8669e7fa63ec1e99fb7bb819a563ca514be2200c669486d40f5a4b152a325ee0adc3abcaa6187b45c1f0ef37ddcb7a86
data/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
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
+
5
15
  ## 0.7.1 (2024-07-25)
6
16
 
7
17
  - Support passing scope options to callable scope objects. ([@palkan][])
@@ -524,3 +534,4 @@ This value is now stored in a cache (if any) instead of just the call result (`t
524
534
  [@tomdalling]: https://github.com/tomdalling
525
535
  [@matsales28]: https://github.com/matsales28
526
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
@@ -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.1"
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.1
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-07-25 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