lib/devise-security/models/password_archivable.rb
def archive_password
        if max_old_passwords.positive?
          return true if old_passwords.where(encrypted_password: encrypted_password_was).exists?

          old_passwords.create!(encrypted_password: encrypted_password_was) if encrypted_password_was.present?
          old_passwords.reorder(created_at: :desc).offset(max_old_passwords).destroy_all
        else
          old_passwords.destroy_all
        end
      end
# Archive the last password before save and delete all to old passwords from archive
# @note we check to see if an old password has already been archived because
#   mongoid will keep re-triggering this callback when we add an old password
Archive the last password before save and delete all to old passwords from archive
Archive the last password before save and delete all to old passwords from archive
def archive_password
        if max_old_passwords.positive?
          return true if old_passwords.where(encrypted_password: encrypted_password_was).exists?
          old_passwords.create!(encrypted_password: encrypted_password_was) if encrypted_password_was.present?
          old_passwords.reorder(created_at: :desc).offset(max_old_passwords).destroy_all
        else
          old_passwords.destroy_all
        end
      end
def archive_password if max_old_passwords . positive? return true if old_passwords . where ( encrypted_password : encrypted_password_was ) . exists? old_passwords . create! ( encrypted_password : encrypted_password_was ) if encrypted_password_was . present? old_passwords . reorder ( created_at : :desc ) . offset ( max_old_passwords ) . destroy_all else old_passwords . destroy_all end end
Archive the last password before save and delete all to old passwords from archive
Archive the last password before save and delete all to old passwords from archive
note
we check to see if an old password has already been archived because mongoid will keep re-triggering this callback when we add an old password
we check to see if an old password has already been archived because mongoid will keep re - triggering this callback when we add an old password