Module: Authlogic::ActsAsAuthentic::Login::Config

Defined in:
lib/authlogic/acts_as_authentic/login.rb

Overview

Configuration for the login field.

Instance Method Summary collapse

Instance Method Details

#find_by_smart_case_login_field(login) ⇒ Object

This method allows you to find a record with the given login. If you notice, with Active Record you have the UniquenessValidator class. They give you a :case_sensitive option. I handle this in the same manner that they handle that. If you are using the login field, set false for the :case_sensitive option in validates_uniqueness_of_login_field_options and the column doesn’t have a case-insensitive collation, this method will modify the query to look something like:

"LOWER(#{quoted_table_name}.#{}) = LOWER(#{})"

If you don’t specify this it just uses a regular case-sensitive search (with the binary modifier if necessary):

"BINARY #{} = #{}"

The above also applies for using email as your login, except that you need to set the :case_sensitive in validates_uniqueness_of_email_field_options to false.



48
49
50
51
52
# File 'lib/authlogic/acts_as_authentic/login.rb', line 48

def ()
  field =  || email_field
  sensitive = Queries::CaseSensitivity.new(self, field).sensitive?
  find_with_case(field, , sensitive)
end

#login_field(value = nil) ⇒ Object Also known as: login_field=

The name of the login field in the database.

  • Default: :login or :username, if they exist

  • Accepts: Symbol



22
23
24
# File 'lib/authlogic/acts_as_authentic/login.rb', line 22

def (value = nil)
  rw_config(:login_field, value, first_column_to_exist(nil, :login, :username))
end