module Authlogic::ActsAsAuthentic::Login::Config

Configuration for the login field.

Public Instance Methods

find_by_smart_case_login_field(login) click to toggle source

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}.#{login_field}) = LOWER(#{login})"

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

"BINARY #{login_field} = #{login}"

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.

@api public

# File lib/authlogic/acts_as_authentic/login.rb, line 48
def find_by_smart_case_login_field(login)
  field = login_field || email_field
  sensitive = Queries::CaseSensitivity.new(self, field).sensitive?
  find_with_case(field, login, sensitive)
end
login_field(value = nil) click to toggle source

The name of the login field in the database.

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

  • Accepts: Symbol

# File lib/authlogic/acts_as_authentic/login.rb, line 22
def login_field(value = nil)
  rw_config(:login_field, value, first_column_to_exist(nil, :login, :username))
end
Also aliased as: login_field=
login_field=(value = nil)
Alias for: login_field

Private Instance Methods

find_with_case(field, value, sensitive) click to toggle source

@api private

# File lib/authlogic/acts_as_authentic/login.rb, line 57
def find_with_case(field, value, sensitive)
  Queries::FindWithCase.new(self, field, value, sensitive).execute
end