def valid_password?(attempted_password, check_against_database = check_passwords_against_database?)
crypted =
if check_against_database && send("#{crypted_password_field}_changed?")
send("#{crypted_password_field}_was")
else
send(crypted_password_field)
end
return false if attempted_password.blank? || crypted.blank?
before_password_verification
crypto_providers.each_with_index do |encryptor, index|
if encryptor_matches?(crypted, encryptor, index, attempted_password, check_against_database)
if transition_password?(index, encryptor, crypted, check_against_database)
transition_password(attempted_password)
end
after_password_verification
return true
end
end
false
end