Module: Devise::Models::LdapNorm::ClassMethods

Defined in:
lib/devise_ldap_norm/model.rb

Instance Method Summary collapse

Instance Method Details

#find_for_ldap_authentication(attributes = {}) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/devise_ldap_norm/model.rb', line 110

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
  auth_key_value.gsub! /[^-\w.@]/i, ''

  resource = new(SecureRandom.uuid)

  resource['remote_ip'] = attributes[:remote_ip]
  resource[auth_key] = auth_key_value
  resource.password = attributes[:password]

  resource
end

#serialize_from_session(id, data = {}) ⇒ Object



102
103
104
# File 'lib/devise_ldap_norm/model.rb', line 102

def serialize_from_session(id, data={})
  self.new(id, data)
end

#serialize_into_session(record) ⇒ Object



106
107
108
# File 'lib/devise_ldap_norm/model.rb', line 106

def serialize_into_session(record)
  [record.id, record.data]
end

#update_with_password(resource) ⇒ Object



127
128
129
# File 'lib/devise_ldap_norm/model.rb', line 127

def update_with_password(resource)
  puts "UPDATE_WITH_PASSWORD: #{resource.inspect}"
end