activemodel 8.1.0.beta1 → 8.1.0.rc1

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: d0477968c49c9249ac55371d34c8035ada03438da3b79f12d53f29179913018a
4
- data.tar.gz: e9481d73df257802b3b69b46837b9806417f2244ecb672c397a2dc9944528799
3
+ metadata.gz: 15e9ea079cc98d8eae87b1d0984234ae0f75b8ef6b4a8b57f54643d5127cdd94
4
+ data.tar.gz: f1880854a5c91b5844a0edb2568602834f0e319d2441cda48773233920f53bf3
5
5
  SHA512:
6
- metadata.gz: 652d349baa6d7d2354878e7e70300036f6529ca8a0e5ef700eca8ed58e936b3d2fa18f293dc69aba2ba3ed7c54bec30631b23070969f7e9e57c18e663f289e15
7
- data.tar.gz: c188746810b0ce0b3645cbc32d288c16864eed5c1ce1c1569a5f6d0aa93b4d761e68bfacb77956be90a3de7449f60d6467813c74e3115a5baddd618190013ea9
6
+ metadata.gz: 2c8e42a8d461ee9d3b525360f66a47e13076464a56334d13314fb39045cea5b9264fbb7b4e15ce276438e918dc3e9162f6e3c21a01d77bb1994ea226d4c8fd33
7
+ data.tar.gz: 67e48079d3fbfd352069a4c0fbb6c4fcf523a461658d7877a1686ca007e3e6c26149d5836b2fac445e50904b006ef025e0aa015d6d2280b49463ccb666876e09
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## Rails 8.1.0.rc1 (October 15, 2025) ##
2
+
3
+ * Add `reset_token: { expires_in: ... }` option to `has_secure_password`.
4
+
5
+ Allows configuring the expiry duration of password reset tokens (default remains 15 minutes for backwards compatibility).
6
+
7
+ ```ruby
8
+ has_secure_password reset_token: { expires_in: 1.hour }
9
+ ```
10
+
11
+ *Jevin Sew*, *Abeid Ahmed*
12
+
1
13
  ## Rails 8.1.0.beta1 (September 04, 2025) ##
2
14
 
3
15
  * Add `except_on:` option for validation callbacks.
@@ -10,7 +10,7 @@ module ActiveModel
10
10
  MAJOR = 8
11
11
  MINOR = 1
12
12
  TINY = 0
13
- PRE = "beta1"
13
+ PRE = "rc1"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -9,6 +9,8 @@ module ActiveModel
9
9
  # Hence need to put a restriction on password length.
10
10
  MAX_PASSWORD_LENGTH_ALLOWED = 72
11
11
 
12
+ DEFAULT_RESET_TOKEN_EXPIRES_IN = 15.minutes
13
+
12
14
  class << self
13
15
  attr_accessor :min_cost # :nodoc:
14
16
  end
@@ -39,10 +41,15 @@ module ActiveModel
39
41
  # <tt>validations: false</tt> as an argument. This allows complete
40
42
  # customizability of validation behavior.
41
43
  #
42
- # Finally, a password reset token that's valid for 15 minutes after issue
43
- # is automatically configured when +reset_token+ is set to true (which it is by default)
44
+ # A password reset token (valid for 15 minutes by default) is automatically
45
+ # configured when +reset_token+ is set to true (which it is by default)
44
46
  # and the object responds to +generates_token_for+ (which Active Records do).
45
47
  #
48
+ # Finally, the reset token expiry can be customized by passing a hash to
49
+ # +has_secure_password+:
50
+ #
51
+ # has_secure_password reset_token: { expires_in: 1.hour }
52
+ #
46
53
  # To use +has_secure_password+, add bcrypt (~> 3.1.7) to your Gemfile:
47
54
  #
48
55
  # gem "bcrypt", "~> 3.1.7"
@@ -160,7 +167,12 @@ module ActiveModel
160
167
 
161
168
  # Only generate tokens for records that are capable of doing so (Active Records, not vanilla Active Models)
162
169
  if reset_token && respond_to?(:generates_token_for)
163
- generates_token_for :"#{attribute}_reset", expires_in: 15.minutes do
170
+ reset_token_expires_in = reset_token.is_a?(Hash) ? reset_token[:expires_in] : DEFAULT_RESET_TOKEN_EXPIRES_IN
171
+
172
+ silence_redefinition_of_method(:"#{attribute}_reset_token_expires_in")
173
+ define_method(:"#{attribute}_reset_token_expires_in") { reset_token_expires_in }
174
+
175
+ generates_token_for :"#{attribute}_reset", expires_in: reset_token_expires_in do
164
176
  public_send(:"#{attribute}_salt")&.last(10)
165
177
  end
166
178
 
@@ -147,14 +147,14 @@ module ActiveModel
147
147
  # or an array of symbols. (e.g. <tt>except: :create</tt> or
148
148
  # <tt>except_on: :custom_validation_context</tt> or
149
149
  # <tt>except_on: [:create, :custom_validation_context]</tt>)
150
- # * <tt>:if</tt> - Specifies a method, proc or string to call to determine
150
+ # * <tt>:if</tt> - Specifies a method or proc to call to determine
151
151
  # if the validation should occur (e.g. <tt>if: :allow_validation</tt>,
152
- # or <tt>if: Proc.new { |user| user.signup_step > 2 }</tt>). The method,
153
- # proc or string should return or evaluate to a +true+ or +false+ value.
154
- # * <tt>:unless</tt> - Specifies a method, proc, or string to call to
152
+ # or <tt>if: Proc.new { |user| user.signup_step > 2 }</tt>). The method or
153
+ # proc should return or evaluate to a +true+ or +false+ value.
154
+ # * <tt>:unless</tt> - Specifies a method or proc to call to
155
155
  # determine if the validation should not occur (e.g. <tt>unless: :skip_validation</tt>,
156
156
  # or <tt>unless: Proc.new { |user| user.signup_step <= 2 }</tt>). The
157
- # method, proc, or string should return or evaluate to a +true+ or +false+
157
+ # method or proc should return or evaluate to a +true+ or +false+
158
158
  # value.
159
159
  #
160
160
  # NOTE: Calling +validate+ multiple times on the same method will overwrite previous definitions.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activemodel
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.1.0.beta1
4
+ version: 8.1.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 8.1.0.beta1
18
+ version: 8.1.0.rc1
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 8.1.0.beta1
25
+ version: 8.1.0.rc1
26
26
  description: A toolkit for building modeling frameworks like Active Record. Rich support
27
27
  for attributes, callbacks, validations, serialization, internationalization, and
28
28
  testing.
@@ -113,10 +113,10 @@ licenses:
113
113
  - MIT
114
114
  metadata:
115
115
  bug_tracker_uri: https://github.com/rails/rails/issues
116
- changelog_uri: https://github.com/rails/rails/blob/v8.1.0.beta1/activemodel/CHANGELOG.md
117
- documentation_uri: https://api.rubyonrails.org/v8.1.0.beta1/
116
+ changelog_uri: https://github.com/rails/rails/blob/v8.1.0.rc1/activemodel/CHANGELOG.md
117
+ documentation_uri: https://api.rubyonrails.org/v8.1.0.rc1/
118
118
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
119
- source_code_uri: https://github.com/rails/rails/tree/v8.1.0.beta1/activemodel
119
+ source_code_uri: https://github.com/rails/rails/tree/v8.1.0.rc1/activemodel
120
120
  rubygems_mfa_required: 'true'
121
121
  rdoc_options: []
122
122
  require_paths: