Module: Devise::Models::PasswordDisallowsFrequentReuse

Extended by:
ActiveSupport::Concern
Defined in:
lib/devise/secure_password/models/password_disallows_frequent_reuse.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#validate_password_frequent_reuseObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/devise/secure_password/models/password_disallows_frequent_reuse.rb', line 21

def validate_password_frequent_reuse
  if encrypted_password_changed? && previous_password?(password)
    error_string = I18n.t(
      'secure_password.password_disallows_frequent_reuse.errors.messages.password_is_recent',
      count: self.class.password_previously_used_count
    )
    errors.add(:base, error_string)
  end

  errors.count.zero?
end