mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00

Throughout the documentations, we are using 'encrypt' incorrectly. Encrypt means that someone will eventually decrypt the message, which is obviously not the case for Devise. I'm changing the docs to use 'hashing' instead. However, I left the database field as `encrypted_password` for now. I'll update the db field in an upcoming PR.
24 lines
838 B
Ruby
24 lines
838 B
Ruby
require 'devise/strategies/authenticatable'
|
|
|
|
module Devise
|
|
module Strategies
|
|
# Default strategy for signing in a user, based on their email and password in the database.
|
|
class DatabaseAuthenticatable < Authenticatable
|
|
def authenticate!
|
|
resource = password.present? && mapping.to.find_for_database_authentication(authentication_hash)
|
|
hashed = false
|
|
|
|
if validate(resource){ hashed = true; resource.valid_password?(password) }
|
|
remember_me(resource)
|
|
resource.after_database_authentication
|
|
success!(resource)
|
|
end
|
|
|
|
mapping.to.new.password = password if !hashed && Devise.paranoid
|
|
fail(:not_found_in_database) unless resource
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
Warden::Strategies.add(:database_authenticatable, Devise::Strategies::DatabaseAuthenticatable)
|