rodauth-model 0.4.0 → 0.5.0

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: aea9e15f1d5a320dba7b2e4cb959b9c8c4358146ac04a09c1bfb2e719a0fb826
4
- data.tar.gz: 5765f24048e014d3cefd3b46bd82d08cdcc98ff0c2d362865fa2e6f17597b3f2
3
+ metadata.gz: 239885866a591579de9572aeef88130ee45bebcdd2950b590471d9b2e2de14ad
4
+ data.tar.gz: 4b507ce9b6fe74cda28363956504f60781e0ed2177c0f30aac287f6a4b65fdac
5
5
  SHA512:
6
- metadata.gz: 3cfe79f030285164d1f3fc36fb1be09a3ca067b282b633870af1a17b341fc9be836d1a93d983dbf211f8e78d9416cc0fd808465470b5256e8e4f9a1b31ed03e0
7
- data.tar.gz: e6ce5e3c754233554c95609405e512ebcf53ce3a608701bc93ebadd63b9aca994404a25feda89669cf20082d9215710d4d6dcf8d958cff4faa82b4227ff00082
6
+ metadata.gz: d0ef6938063f04122115959b51d833c8f84441526e721493a5af518c7758dcabcf4022b7a0701e6dc69ba098b4519fd35126952b15b56ac3465d0e18ad31f9fa
7
+ data.tar.gz: bbf525d94b4533f11485428f258fd3963e79b896a2dfeebc9240565ae25e5e12d5c5eeb86fa6e96ad05d4075cb2a8f03b3c289246d1c4569d5f3e11ea7aafabe
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.5.0 (2026-06-29)
2
+
3
+ * Don't define the password hash association when no password feature is enabled, which previously failed on `Account#destroy` for setups such as OmniAuth-only authentication (@janko)
4
+
1
5
  ## 0.4.0 (2024-12-16)
2
6
 
3
7
  * Add `password?` model method that returns whether a password is set (@janko)
data/README.md CHANGED
@@ -152,7 +152,7 @@ if defined?(Rodauth::Model)
152
152
  end
153
153
  ```
154
154
 
155
- The `Rodauth::Model.register_association` method receives the feature name and a block, which is evaluted in the context of a Rodauth instance and should return the association definition with the following items:
155
+ The `Rodauth::Model.register_association` method receives the feature name and a block, which is evaluated in the context of a Rodauth instance and should return the association definition with the following items:
156
156
 
157
157
  * `:name` – association name
158
158
  * `:type` – relationship type (`:one` for one-to-one, `:many` for one-to-many)
@@ -43,7 +43,7 @@ module Rodauth
43
43
  end
44
44
 
45
45
  def define_associations(model)
46
- define_password_hash_association(model) unless rodauth.account_password_hash_column
46
+ define_password_hash_association(model) if password_hash_association?
47
47
 
48
48
  feature_associations.each do |association|
49
49
  association[:type] = ASSOCIATION_TYPES.fetch(association[:type])
@@ -14,7 +14,7 @@ module Rodauth
14
14
  def define_methods(model)
15
15
  rodauth = @auth_class.allocate.freeze
16
16
 
17
- unless rodauth.account_password_hash_column
17
+ if password_hash_association?
18
18
  model.plugin :nested_attributes
19
19
  model.nested_attributes :password_hash, destroy: true
20
20
  end
@@ -55,7 +55,7 @@ module Rodauth
55
55
  def define_associations(model)
56
56
  model.plugin :association_dependencies
57
57
 
58
- define_password_hash_association(model) unless rodauth.account_password_hash_column
58
+ define_password_hash_association(model) if password_hash_association?
59
59
 
60
60
  feature_associations.each do |association|
61
61
  association[:type] = ASSOCIATION_TYPES.fetch(association[:type])
data/lib/rodauth/model.rb CHANGED
@@ -52,6 +52,15 @@ module Rodauth
52
52
  .map { |block| rodauth.instance_exec(&block) }
53
53
  end
54
54
 
55
+ # The password hash is stored in a separate table only when Rodauth is
56
+ # configured to manage passwords (i.e. when a password-handling feature is
57
+ # enabled). Without this check we'd define an association against a table
58
+ # that doesn't exist, which would fail on Account#destroy.
59
+ def password_hash_association?
60
+ !rodauth.account_password_hash_column &&
61
+ rodauth.features.include?(:login_password_requirements_base)
62
+ end
63
+
55
64
  def rodauth
56
65
  @auth_class.allocate
57
66
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "rodauth-model"
5
- spec.version = "0.4.0"
5
+ spec.version = "0.5.0"
6
6
  spec.authors = ["Janko Marohnić"]
7
7
  spec.email = ["janko@hey.com"]
8
8
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rodauth-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2024-12-26 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rodauth
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
157
  - !ruby/object:Gem::Version
158
158
  version: '0'
159
159
  requirements: []
160
- rubygems_version: 3.6.2
160
+ rubygems_version: 4.0.13
161
161
  specification_version: 4
162
162
  summary: Provides model mixin for Active Record and Sequel that defines password attribute
163
163
  and associations based on Rodauth configuration.