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

### Home Classes Methods

### In Files

- lib/authlogic/acts_as_authentic/login.rb

### Methods

- #find_by_smart_case_login_field
- #login_field
- #login_field=
- #merge_validates_format_of_login_field_options
- #merge_validates_length_of_login_field_options
- #merge_validates_uniqueness_of_login_field_options
- #validate_login_field
- #validate_login_field=
- #validates_format_of_login_field_options
- #validates_format_of_login_field_options=
- #validates_length_of_login_field_options
- #validates_length_of_login_field_options=
- #validates_uniqueness_of_login_field_options
- #validates_uniqueness_of_login_field_options=

### Files

- LICENSE
- README.rdoc

### Class/Module Index

Quicksearch

- Authlogic
- Authlogic::ActsAsAuthentic
- Authlogic::ActsAsAuthentic::Base
- Authlogic::ActsAsAuthentic::Base::Config
- Authlogic::ActsAsAuthentic::Email
- Authlogic::ActsAsAuthentic::Email::Config
- Authlogic::ActsAsAuthentic::Email::Methods
- Authlogic::ActsAsAuthentic::LoggedInStatus
- Authlogic::ActsAsAuthentic::LoggedInStatus::Config
- Authlogic::ActsAsAuthentic::LoggedInStatus::Methods
- Authlogic::ActsAsAuthentic::LoggedInStatus::Methods::InstanceMethods
- Authlogic::ActsAsAuthentic::Login
- Authlogic::ActsAsAuthentic::Login::Config
- Authlogic::ActsAsAuthentic::Login::Methods
- Authlogic::ActsAsAuthentic::MagicColumns
- Authlogic::ActsAsAuthentic::MagicColumns::Methods
- Authlogic::ActsAsAuthentic::Password
- Authlogic::ActsAsAuthentic::Password::Callbacks
- Authlogic::ActsAsAuthentic::Password::Config
- Authlogic::ActsAsAuthentic::Password::Methods
- Authlogic::ActsAsAuthentic::Password::Methods::InstanceMethods
- Authlogic::ActsAsAuthentic::PerishableToken
- Authlogic::ActsAsAuthentic::PerishableToken::Config
- Authlogic::ActsAsAuthentic::PerishableToken::Methods
- Authlogic::ActsAsAuthentic::PerishableToken::Methods::ClassMethods
- Authlogic::ActsAsAuthentic::PerishableToken::Methods::InstanceMethods
- Authlogic::ActsAsAuthentic::PersistenceToken
- Authlogic::ActsAsAuthentic::PersistenceToken::Methods
- Authlogic::ActsAsAuthentic::PersistenceToken::Methods::ClassMethods
- Authlogic::ActsAsAuthentic::PersistenceToken::Methods::InstanceMethods
- Authlogic::ActsAsAuthentic::RestfulAuthentication
- Authlogic::ActsAsAuthentic::RestfulAuthentication::Config
- Authlogic::ActsAsAuthentic::RestfulAuthentication::InstanceMethods
- Authlogic::ActsAsAuthentic::SessionMaintenance
- Authlogic::ActsAsAuthentic::SessionMaintenance::Config
- Authlogic::ActsAsAuthentic::SessionMaintenance::Methods
- Authlogic::ActsAsAuthentic::SingleAccessToken
- Authlogic::ActsAsAuthentic::SingleAccessToken::Config
- Authlogic::ActsAsAuthentic::SingleAccessToken::Methods
- Authlogic::ActsAsAuthentic::SingleAccessToken::Methods::InstanceMethods
- Authlogic::ActsAsAuthentic::ValidationsScope
- Authlogic::ActsAsAuthentic::ValidationsScope::Config
- Authlogic::AuthenticatesMany
- Authlogic::AuthenticatesMany::Association
- Authlogic::AuthenticatesMany::Base
- Authlogic::ControllerAdapters
- Authlogic::ControllerAdapters::AbstractAdapter
- Authlogic::ControllerAdapters::MerbAdapter
- Authlogic::ControllerAdapters::MerbAdapter::MerbImplementation
- Authlogic::ControllerAdapters::RailsAdapter
- Authlogic::ControllerAdapters::RailsAdapter::AuthlogicLoadedTooLateError
- Authlogic::ControllerAdapters::RailsAdapter::RailsImplementation
- Authlogic::ControllerAdapters::SinatraAdapter
- Authlogic::ControllerAdapters::SinatraAdapter::Adapter
- Authlogic::ControllerAdapters::SinatraAdapter::Adapter::Implementation
- Authlogic::ControllerAdapters::SinatraAdapter::Controller
- Authlogic::ControllerAdapters::SinatraAdapter::Cookies
- Authlogic::CryptoProviders
- Authlogic::CryptoProviders::AES256
- Authlogic::CryptoProviders::BCrypt
- Authlogic::CryptoProviders::MD5
- Authlogic::CryptoProviders::Sha1
- Authlogic::CryptoProviders::Sha256
- Authlogic::CryptoProviders::Sha512
- Authlogic::CryptoProviders::Wordpress
- Authlogic::I18n
- Authlogic::I18n::Translator
- Authlogic::Random
- Authlogic::Regex
- Authlogic::Session
- Authlogic::Session::Activation
- Authlogic::Session::Activation::ClassMethods
- Authlogic::Session::Activation::InstanceMethods
- Authlogic::Session::ActiveRecordTrickery
- Authlogic::Session::ActiveRecordTrickery::ClassMethods
- Authlogic::Session::ActiveRecordTrickery::InstanceMethods
- Authlogic::Session::Base
- Authlogic::Session::BruteForceProtection
- Authlogic::Session::BruteForceProtection::Config
- Authlogic::Session::BruteForceProtection::InstanceMethods
- Authlogic::Session::Callbacks
- Authlogic::Session::Cookies
- Authlogic::Session::Cookies::Config
- Authlogic::Session::Cookies::InstanceMethods
- Authlogic::Session::Existence
- Authlogic::Session::Existence::ClassMethods
- Authlogic::Session::Existence::InstanceMethods
- Authlogic::Session::Foundation
- Authlogic::Session::Foundation::ClassMethods
- Authlogic::Session::Foundation::InstanceMethods
- Authlogic::Session::HttpAuth
- Authlogic::Session::HttpAuth::Config
- Authlogic::Session::HttpAuth::InstanceMethods
- Authlogic::Session::Id
- Authlogic::Session::Klass
- Authlogic::Session::Klass::Config
- Authlogic::Session::Klass::InstanceMethods
- Authlogic::Session::MagicColumns
- Authlogic::Session::MagicColumns::Config
- Authlogic::Session::MagicColumns::InstanceMethods
- Authlogic::Session::MagicStates
- Authlogic::Session::MagicStates::Config
- Authlogic::Session::MagicStates::InstanceMethods
- Authlogic::Session::Params
- Authlogic::Session::Params::Config
- Authlogic::Session::Params::InstanceMethods
- Authlogic::Session::Password
- Authlogic::Session::Password::Config
- Authlogic::Session::Password::InstanceMethods
- Authlogic::Session::PerishableToken
- Authlogic::Session::Persistence
- Authlogic::Session::Persistence::ClassMethods
- Authlogic::Session::Persistence::InstanceMethods
- Authlogic::Session::PriorityRecord
- Authlogic::Session::Scopes
- Authlogic::Session::Scopes::ClassMethods
- Authlogic::Session::Scopes::InstanceMethods
- Authlogic::Session::Session
- Authlogic::Session::Session::Config
- Authlogic::Session::Session::InstanceMethods
- Authlogic::Session::Timeout
- Authlogic::Session::Timeout::Config
- Authlogic::Session::Timeout::InstanceMethods
- Authlogic::Session::UnauthorizedRecord
- Authlogic::Session::Validation
- Authlogic::Session::Validation::Errors
- Authlogic::TestCase
- Authlogic::TestCase::MockController
- Authlogic::TestCase::MockLogger
- Authlogic::TestCase::RailsRequestAdapter
- Object

No matching classes.

# Authlogic::ActsAsAuthentic::Login::Config

Confguration 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 ActiveRecord you have the validates_uniqueness_of validation function. 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 and set false for the :case_sensitive option in validates_uniqueness_of_login_field_options this method will modify the query to look something like:

    first(:conditions => ["LOWER(#{quoted_table_name}.#{login_field}) = ?", login.downcase])

If you don’t specify this it calls the good old find_by_* method:

    find_by_login(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.

The only reason I need to do the above is for Postgres and SQLite since they perform case sensitive searches with the find_by_* methods.

    # File lib/authlogic/acts_as_authentic/login.rb, line 108
    def find_by_smart_case_login_field(login)
      if login_field
        find_with_case(login_field, login, validates_uniqueness_of_login_field_options[:case_sensitive] != false)
      else
        find_with_case(email_field, login, validates_uniqueness_of_email_field_options[:case_sensitive] != false)
      end
    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 18
    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) click to toggle source
Alias for: login_field
merge_validates_format_of_login_field_options(options = {}) click to toggle source

See merge_validates_length_of_login_field_options. The same thing, except for validates_format_of_login_field_options

    # File lib/authlogic/acts_as_authentic/login.rb, line 70
    def merge_validates_format_of_login_field_options(options = {})
      self.validates_format_of_login_field_options = validates_format_of_login_field_options.merge(options)
    end

merge_validates_length_of_login_field_options(options = {}) click to toggle source

A convenience function to merge options into the validates_length_of_login_field_options. So intead of:

    self.validates_length_of_login_field_options = validates_length_of_login_field_options.merge(:my_option => my_value)

You can do this:

    merge_validates_length_of_login_field_options :my_option => my_value

    # File lib/authlogic/acts_as_authentic/login.rb, line 52
    def merge_validates_length_of_login_field_options(options = {})
      self.validates_length_of_login_field_options = validates_length_of_login_field_options.merge(options)
    end

merge_validates_uniqueness_of_login_field_options(options = {}) click to toggle source

See merge_validates_length_of_login_field_options. The same thing, except for validates_uniqueness_of_login_field_options

    # File lib/authlogic/acts_as_authentic/login.rb, line 88
    def merge_validates_uniqueness_of_login_field_options(options = {})
      self.validates_uniqueness_of_login_field_options = validates_uniqueness_of_login_field_options.merge(options)
    end

validate_login_field(value = nil) click to toggle source

Whether or not the validate the login field

- `Default:` true

- `Accepts:` Boolean

    # File lib/authlogic/acts_as_authentic/login.rb, line 27
    def validate_login_field(value = nil)
      rw_config(:validate_login_field, value, true)
    end

Also aliased as: validate_login_field=
validate_login_field=(value = nil) click to toggle source
Alias for: validate_login_field
validates_format_of_login_field_options(value = nil) click to toggle source

A hash of options for the validates_format_of call for the login field. Allows you to change this however you want.

Keep in mind this is ruby. I wanted to keep this as flexible as possible, so you can completely replace the hash or merge options into it. Checkout the convenience function merge_validates_format_of_login_field_options to merge options.

- `Default:` {:with => Authlogic::Regex.login, :message => I18n.t('error_messages.login_invalid', :default => "should use only letters, numbers, spaces, and .-_@ please.")}

- `Accepts:` Hash of options accepted by validates_format_of

    # File lib/authlogic/acts_as_authentic/login.rb, line 64
    def validates_format_of_login_field_options(value = nil)
      rw_config(:validates_format_of_login_field_options, value, {:with => Authlogic::Regex.login, :message => I18n.t('error_messages.login_invalid', :default => "should use only letters, numbers, spaces, and .-_@ please.")})
    end

Also aliased as: validates_format_of_login_field_options=
validates_format_of_login_field_options=(value = nil) click to toggle source
Alias for: validates_format_of_login_field_options
validates_length_of_login_field_options(value = nil) click to toggle source

A hash of options for the validates_length_of call for the login field. Allows you to change this however you want.

Keep in mind this is ruby. I wanted to keep this as flexible as possible, so you can completely replace the hash or merge options into it. Checkout the convenience function merge_validates_length_of_login_field_options to merge options.

- `Default:` {:within => 3..100}

- `Accepts:` Hash of options accepted by validates_length_of

    # File lib/authlogic/acts_as_authentic/login.rb, line 40
    def validates_length_of_login_field_options(value = nil)
      rw_config(:validates_length_of_login_field_options, value, {:within => 3..100})
    end

Also aliased as: validates_length_of_login_field_options=
validates_length_of_login_field_options=(value = nil) click to toggle source
Alias for: validates_length_of_login_field_options
validates_uniqueness_of_login_field_options(value = nil) click to toggle source

A hash of options for the validates_uniqueness_of call for the login field. Allows you to change this however you want.

Keep in mind this is ruby. I wanted to keep this as flexible as possible, so you can completely replace the hash or merge options into it. Checkout the convenience function merge_validates_format_of_login_field_options to merge options.

- `Default:` {:case_sensitive => false, :scope => validations_scope, :if => "#{login_field}_changed?".to_sym}

- `Accepts:` Hash of options accepted by validates_uniqueness_of

    # File lib/authlogic/acts_as_authentic/login.rb, line 82
    def validates_uniqueness_of_login_field_options(value = nil)
      rw_config(:validates_uniqueness_of_login_field_options, value, {:case_sensitive => false, :scope => validations_scope, :if => "#{login_field}_changed?".to_sym})
    end

Also aliased as: validates_uniqueness_of_login_field_options=
validates_uniqueness_of_login_field_options=(value = nil) click to toggle source
Alias for: validates_uniqueness_of_login_field_options

[Validate]

Generated with the Darkfish Rdoc Generator 2.