module Devise::Models::LdapAuthenticatable::ClassMethods

Public Instance Methods

find_for_ldap_authentication(attributes={}) click to toggle source

Find a user for ldap authentication.

# File lib/devise_ldap_authenticatable/model.rb, line 90
def find_for_ldap_authentication(attributes={})
  auth_key = self.authentication_keys.first
  return nil unless attributes[auth_key].present?

  auth_key_value = (self.case_insensitive_keys || []).include?(auth_key) ? attributes[auth_key].downcase : attributes[auth_key]
  auth_key_value = (self.strip_whitespace_keys || []).include?(auth_key) ? auth_key_value.strip : auth_key_value

  resource = where(auth_key => auth_key_value).first

  if resource.blank?
    resource = new
    resource[auth_key] = auth_key_value
    resource.password = attributes[:password]
  end

  if ::Devise.ldap_create_user && resource.new_record? && resource.valid_ldap_authentication?(attributes[:password])
    resource.ldap_before_save if resource.respond_to?(:ldap_before_save)
    resource.save!
  end

  resource
end
update_with_password(resource) click to toggle source
# File lib/devise_ldap_authenticatable/model.rb, line 113
def update_with_password(resource)
  puts "UPDATE_WITH_PASSWORD: #{resource.inspect}"
end