mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
20 lines
606 B
Ruby
20 lines
606 B
Ruby
require 'devise/strategies/authenticatable'
|
|
|
|
module Devise
|
|
module Strategies
|
|
# Default strategy for signing in a user, based on his email and password in the database.
|
|
class DatabaseAuthenticatable < Authenticatable
|
|
def authenticate!
|
|
resource = mapping.to.find_for_database_authentication(authentication_hash)
|
|
|
|
if validate(resource){ resource.valid_password?(password) }
|
|
success!(resource)
|
|
else
|
|
fail(:invalid)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
Warden::Strategies.add(:database_authenticatable, Devise::Strategies::DatabaseAuthenticatable)
|