rodauth-model 0.2.1 → 0.3.0

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: 59bbf27ffd624fa72ce609fcb9968118bf358e3e3f10893db7d0d73abf356d12
4
- data.tar.gz: 2c286827b98cef9f1d593f740375ae2f74c759dee7dd2d7c954380a03659ecd4
3
+ metadata.gz: 91293093585a6bb8cc89572b0a646e7c467791760d1bb3d042447a88865bdfbe
4
+ data.tar.gz: 4660747afb36a135a67d7d3da9018ec4e9d98e9d900e5677713c6cbca76cc36c
5
5
  SHA512:
6
- metadata.gz: a8ef44bd93fc5cdb4fabaf58544bcf3ddc7ab8084a6a38b73777cb26163fe0ad8ded45978975cf4423b8f44b97e1c49dc9d3d01f6ca7aac71f06d120a7bebf5b
7
- data.tar.gz: 9d8067365baec855fed3ad8f2db189d8842e3244b2867ca6b67413715ddd15465aa7f5db1d416f80e4925df2b226f7edda80e68cd40a83a0697e7a1cfe669644
6
+ metadata.gz: 78e60ba11059f42980909f23b3862bc25d1ac921f34e4124430034d4c61a7d69f79524f1d73447c3310a691819f426a52f51427a398792663b78a70833754979
7
+ data.tar.gz: 257afaa7f30a76cdfe633586a70c9dafba41c9653e9b346ba9a839ecaa86f4846854ffa332217bfbee1c859839748e79dc8b1755cbb0ee986be0c0815897c7e7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.3.0 (2024-10-12)
2
+
3
+ * Add support for OTP Unlock feature (@janko)
4
+
1
5
  ## 0.2.1 (2022-10-26)
2
6
 
3
7
  * Fix `elsif` warning in sequel code (@janko)
data/README.md CHANGED
@@ -27,14 +27,6 @@ class Account < ActiveRecord::Base # Sequel::Model
27
27
  end
28
28
  ```
29
29
 
30
- If you have multiple Rodauth configurations, pass the one for which you want associations to be defined.
31
-
32
- ```rb
33
- class Account < ActiveRecord::Base # Sequel::Model
34
- include Rodauth::Model(RodauthApp.rodauth(:admin))
35
- end
36
- ```
37
-
38
30
  ### Password attribute
39
31
 
40
32
  Regardless of whether you're storing the password hash in a column in the accounts table, or in a separate table, the `#password` attribute can be used to set or clear the password hash.
@@ -91,6 +83,20 @@ Rodauth::Model(RodauthApp.rodauth, association_options: -> (name) {
91
83
  })
92
84
  ```
93
85
 
86
+ ### Extending models
87
+
88
+ When using Zeitwerk autoloading, extending an associated model in a separate file won't work, because Zeitwerk has no reason to load it, since the constant was already defined. You can work around this by extending the model in the parent file:
89
+
90
+ ```rb
91
+ class Account < ActiveRecord::Base
92
+ include Rodauth::Model(RodauthApp.rodauth) # defines associated models
93
+
94
+ class ActiveSessionKey < ActiveRecord::Base
95
+ # extend the model
96
+ end
97
+ end
98
+ ```
99
+
94
100
  ## Association reference
95
101
 
96
102
  Below is a list of all associations defined depending on the features loaded:
@@ -131,11 +137,11 @@ module Rodauth
131
137
  auth_value_method :foo_id_column, :id
132
138
  # ...
133
139
  end
140
+ end
134
141
 
135
- if defined?(Model)
136
- Model.register_association(:foo) do
137
- { name: :foo, type: :one, table: foo_table, key: foo_id_column }
138
- end
142
+ if defined?(Rodauth::Model)
143
+ Rodauth::Model.register_association(:foo) do
144
+ { name: :foo, type: :one, table: foo_table, key: foo_id_column }
139
145
  end
140
146
  end
141
147
  ```
@@ -16,7 +16,7 @@ module Rodauth
16
16
 
17
17
  define_method(:password=) do |password|
18
18
  @password = password
19
- password_hash = rodauth.send(:password_hash, password) if password
19
+ password_hash = rodauth.password_hash(password) if password
20
20
  set_password_hash(password_hash)
21
21
  end
22
22
 
@@ -46,6 +46,9 @@ module Rodauth
46
46
  Model.register_association(:otp) do
47
47
  { name: :otp_key, type: :one, table: otp_keys_table, key: otp_keys_id_column }
48
48
  end
49
+ Model.register_association(:otp_unlock) do
50
+ { name: :otp_unlock, type: :one, table: otp_unlock_table, key: otp_unlock_id_column }
51
+ end
49
52
  Model.register_association(:sms_codes) do
50
53
  { name: :sms_code, type: :one, table: sms_codes_table, key: sms_id_column }
51
54
  end
@@ -23,7 +23,7 @@ module Rodauth
23
23
 
24
24
  define_method(:password=) do |password|
25
25
  @password = password
26
- password_hash = rodauth.send(:password_hash, password) if password
26
+ password_hash = rodauth.password_hash(password) if password
27
27
  set_password_hash(password_hash)
28
28
  end
29
29
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "rodauth-model"
5
- spec.version = "0.2.1"
5
+ spec.version = "0.3.0"
6
6
  spec.authors = ["Janko Marohnić"]
7
7
  spec.email = ["janko@hey.com"]
8
8
 
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.files = Dir["README.md", "LICENSE.txt", "CHANGELOG.md", "lib/**/*", "*.gemspec"]
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_dependency "rodauth", "~> 2.0"
20
+ spec.add_dependency "rodauth", "~> 2.28"
21
21
 
22
22
  spec.add_development_dependency "minitest"
23
23
  spec.add_development_dependency "minitest-hooks"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rodauth-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-26 00:00:00.000000000 Z
11
+ date: 2024-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rodauth
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '2.28'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '2.28'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  - !ruby/object:Gem::Version
160
160
  version: '0'
161
161
  requirements: []
162
- rubygems_version: 3.3.3
162
+ rubygems_version: 3.5.11
163
163
  signing_key:
164
164
  specification_version: 4
165
165
  summary: Provides model mixin for Active Record and Sequel that defines password attribute