diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2014-01-07 07:59:24 -0200 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2014-01-07 07:59:44 -0200 |
commit | 3a33e8ea85f025d5ba575318583d1038889a2ba1 (patch) | |
tree | bfeec6dadd2c8d267711f452f9131a5e96935dbb /activemodel | |
parent | 017b0fb08a221fe6b1bb73946c3e365daf80bb39 (diff) | |
download | rails-3a33e8ea85f025d5ba575318583d1038889a2ba1.tar.gz rails-3a33e8ea85f025d5ba575318583d1038889a2ba1.tar.bz2 rails-3a33e8ea85f025d5ba575318583d1038889a2ba1.zip |
Use a better method name to check the requirement of password confirmation
Also improve changelog entries related to secure password to proper
highlight.
Diffstat (limited to 'activemodel')
-rw-r--r-- | activemodel/CHANGELOG.md | 6 | ||||
-rw-r--r-- | activemodel/lib/active_model/secure_password.rb | 10 |
2 files changed, 8 insertions, 8 deletions
diff --git a/activemodel/CHANGELOG.md b/activemodel/CHANGELOG.md index 42cf58a870..09fdd84844 100644 --- a/activemodel/CHANGELOG.md +++ b/activemodel/CHANGELOG.md @@ -19,8 +19,8 @@ *Bogdan Gusiev* -* Fix has_secure_password. `password_confirmation` validations are triggered - even if no `password_confirmation` is set. +* Fix `has_secure_password` not to trigger `password_confirmation` validations + if no `password_confirmation` is set. *Vladimir Kiselev* @@ -33,7 +33,7 @@ *Charles Bergeron* -* Fix regression in has_secure_password. When a password is set, but a +* Fix regression in `has_secure_password`. When a password is set, but a confirmation is an empty string, it would incorrectly save. *Steve Klabnik* and *Phillip Calvin* diff --git a/activemodel/lib/active_model/secure_password.rb b/activemodel/lib/active_model/secure_password.rb index 9d891b9ddc..d824a66784 100644 --- a/activemodel/lib/active_model/secure_password.rb +++ b/activemodel/lib/active_model/secure_password.rb @@ -57,9 +57,9 @@ module ActiveModel include InstanceMethodsOnActivation if options.fetch(:validations, true) - validates_confirmation_of :password, if: :should_confirm_password? + validates_confirmation_of :password, if: :password_confirmation_required? validates_presence_of :password, on: :create - validates_presence_of :password_confirmation, if: :should_confirm_password? + validates_presence_of :password_confirmation, if: :password_confirmation_required? before_create { raise "Password digest missing on new record" if password_digest.blank? } end @@ -113,9 +113,9 @@ module ActiveModel private - def should_confirm_password? - password_confirmation && password.present? - end + def password_confirmation_required? + password_confirmation && password.present? + end end end end |