Module: Devise::Models::DatabaseAuthenticatable::ClassMethods
- Defined in:
- lib/devise/models/database_authenticatable.rb
Instance Method Summary collapse
-
#authenticate(attributes = {}) ⇒ Object
Authenticate a user based on configured attribute keys.
-
#encryptor_class ⇒ Object
Returns the class for the configured encryptor.
Instance Method Details
#authenticate(attributes = {}) ⇒ Object
Authenticate a user based on configured attribute keys. Returns the authenticated user if it’s valid or nil.
114 115 116 117 118 119 |
# File 'lib/devise/models/database_authenticatable.rb', line 114 def authenticate(attributes={}) return unless authentication_keys.all? { |k| attributes[k].present? } conditions = attributes.slice(*authentication_keys) resource = find_for_authentication(conditions) resource if resource.try(:valid_for_authentication?, attributes) end |
#encryptor_class ⇒ Object
Returns the class for the configured encryptor.
122 123 124 |
# File 'lib/devise/models/database_authenticatable.rb', line 122 def encryptor_class @encryptor_class ||= ::Devise::Encryptors.const_get(encryptor.to_s.classify) end |