Module: Devise::Models::PasswordArchivable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/protected/password_archiveable.rb
Overview
PasswordArchivable
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#password_archive_included? ⇒ Boolean
validate is the password used in the past.
- #validate_password_archive ⇒ Object
Instance Method Details
#password_archive_included? ⇒ Boolean
validate is the password used in the past
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/protected/password_archiveable.rb', line 19 def password_archive_included? unless self.class.deny_old_passwords.is_a? Fixnum if self.class.deny_old_passwords.is_a? TrueClass and self.class.password_archiving_count > 0 self.class.deny_old_passwords = self.class.password_archiving_count else self.class.deny_old_passwords = 0 end end if self.class.deny_old_passwords > 0 and not self.password.nil? self.old_passwords.order('created_at DESC').limit(self.class.deny_old_passwords).each do |old_password| dummy = self.class.new dummy.encrypted_password = old_password.encrypted_password dummy.password_salt = old_password.password_salt if dummy.respond_to?(:password_salt) return true if dummy.valid_password?(self.password) end end false end |
#validate_password_archive ⇒ Object
14 15 16 |
# File 'lib/protected/password_archiveable.rb', line 14 def validate_password_archive self.errors.add(:password, :taken_in_past) if encrypted_password_changed? and password_archive_included? end |