Module: Devise::Models::Authenticatable::ClassMethods
- Defined in:
- lib/devise/models/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.
116 117 118 119 120 121 |
# File 'lib/devise/models/authenticatable.rb', line 116 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.
124 125 126 |
# File 'lib/devise/models/authenticatable.rb', line 124 def encryptor_class @encryptor_class ||= ::Devise::Encryptors.const_get(encryptor.to_s.classify) end |