Skip to content

Commit

Permalink
Update to avoid depreciation notices for encrypted_password_changed.
Browse files Browse the repository at this point in the history
Changes to `will_save_change_to_encrypted_password` in Rails 5.2+.
  • Loading branch information
natebird committed Feb 7, 2018
1 parent 1102b57 commit 86f9573
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/devise-security/models/password_archivable.rb
Expand Up @@ -11,7 +11,7 @@ module PasswordArchivable
end

def validate_password_archive
errors.add(:password, :taken_in_past) if encrypted_password_changed? && password_archive_included?
errors.add(:password, :taken_in_past) if will_save_change_to_encrypted_password? && password_archive_included?
end

# validate is the password used in the past
Expand Down Expand Up @@ -58,7 +58,7 @@ def archive_count

# archive the last password before save and delete all to old passwords from archive
def archive_password
if encrypted_password_changed?
if saved_change_to_encrypted_password?
if archive_count.to_i > 0
old_passwords.create! old_password_params
old_passwords.order(:id).reverse_order.offset(archive_count).destroy_all
Expand Down
2 changes: 1 addition & 1 deletion lib/devise-security/models/password_expirable.rb
Expand Up @@ -48,7 +48,7 @@ def expire_password_after

# is password changed then update password_cahanged_at
def update_password_changed
self.password_changed_at = Time.now if (self.new_record? || self.encrypted_password_changed?) && !self.password_changed_at_changed?
self.password_changed_at = Time.now if (self.new_record? || self.will_save_change_to_encrypted_password?) && !self.will_save_change_to_password_changed_at?
end

def expired_password_after_numeric?
Expand Down
4 changes: 2 additions & 2 deletions lib/devise-security/models/secure_validatable.rb
Expand Up @@ -21,7 +21,7 @@ def self.included(base)

# validate login in a strict way if not yet validated
unless has_uniqueness_validation_of_login?
validation_condition = "#{login_attribute}_changed?".to_sym
validation_condition = "will_save_change_to_#{login_attribute}?".to_sym

validates login_attribute, :uniqueness => {
:scope => authentication_keys[1..-1],
Expand All @@ -35,7 +35,7 @@ def self.included(base)
unless devise_validation_enabled?
validates :email, :presence => true, :if => :email_required?
unless already_validated_email
validates :email, :uniqueness => true, :allow_blank => true, :if => :email_changed? # check uniq for email ever
validates :email, :uniqueness => true, :allow_blank => true, :if => :will_save_change_to_email? # check uniq for email ever
end

validates :password, :presence => true, :length => password_length, :confirmation => true, :if => :password_required?
Expand Down

0 comments on commit 86f9573

Please sign in to comment.