Module: DeviseBasecamper::Authentication::ClassMethods

Defined in:
lib/devise-basecamper/authentication.rb

Instance Method Summary collapse

Instance Method Details

#authenticate_with_login?(conditions = {}) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
# File 'lib/devise-basecamper/authentication.rb', line 25

def authenticate_with_login?(conditions={})
  if conditions.any?
    authentication_keys.include?(basecamper[:login_attribute]) && conditions.include?(basecamper[:login_attribute])
  else
    authentication_keys.include? basecamper[:login_attribute]
  end
end

#find_for_authentication(conditions = {}) ⇒ Object

Override the find_for_authentication finder

We will clean the conditions provided to make sure that the proper resource can/will be found.



14
15
16
17
18
19
20
21
22
23
# File 'lib/devise-basecamper/authentication.rb', line 14

def find_for_authentication(conditions={})
  conditions = clean_conditions_for_subdomain(conditions)

  ## Process if "login" key used instead of default (:email)
  if authenticate_with_login?(conditions)
    ( authentication_keys, conditions )
  else
    super ## Execute original find_for_authentication code
  end
end