1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00
heartcombo--devise/lib/devise/strategies/database_authenticatable.rb

22 lines
674 B
Ruby
Raw Normal View History

require 'devise/strategies/authenticatable'
2009-12-07 17:26:00 -05:00
2009-10-18 09:15:23 -04:00
module Devise
module Strategies
# Default strategy for signing in a user, based on his email and password in the database.
class DatabaseAuthenticatable < Authenticatable
2009-10-18 09:15:23 -04:00
def authenticate!
resource = valid_password? && mapping.to.find_for_database_authentication(authentication_hash)
if validate(resource){ resource.valid_password?(password) }
resource.after_database_authentication
success!(resource)
2009-10-18 09:15:23 -04:00
else
fail(:invalid)
2009-10-18 09:15:23 -04:00
end
end
end
end
end
Warden::Strategies.add(:database_authenticatable, Devise::Strategies::DatabaseAuthenticatable)