Bookmark and Share
Filter_button (37/54)
Search_button

Authlogic::ActsAsAuthentic::Login::Config module

Confguration for the login field.

Methods

Name Visibility Source
find_by_smart_case_login_field public instance Authlogic::ActsAsAuthentic::Login::Config (authlogic 2.1.3)
find_with_case private instance Authlogic::ActsAsAuthentic::Login::Config (authlogic 2.1.3)
login_field public instance Authlogic::ActsAsAuthentic::Login::Config (authlogic 2.1.3)
login_field= public instance Authlogic::ActsAsAuthentic::Login::Config (authlogic 2.1.3)
merge_validates_format_of_login_field_options public instance Authlogic::ActsAsAuthentic::Login::Config (authlogic 2.1.3)
merge_validates_length_of_login_field_options public instance Authlogic::ActsAsAuthentic::Login::Config (authlogic 2.1.3)
merge_validates_uniqueness_of_login_field_options public instance Authlogic::ActsAsAuthentic::Login::Config (authlogic 2.1.3)
validate_login_field public instance Authlogic::ActsAsAuthentic::Login::Config (authlogic 2.1.3)
validate_login_field= public instance Authlogic::ActsAsAuthentic::Login::Config (authlogic 2.1.3)
validates_format_of_login_field_options public instance Authlogic::ActsAsAuthentic::Login::Config (authlogic 2.1.3)
validates_format_of_login_field_options= public instance Authlogic::ActsAsAuthentic::Login::Config (authlogic 2.1.3)
validates_length_of_login_field_options public instance Authlogic::ActsAsAuthentic::Login::Config (authlogic 2.1.3)
validates_length_of_login_field_options= public instance Authlogic::ActsAsAuthentic::Login::Config (authlogic 2.1.3)
validates_uniqueness_of_login_field_options public instance Authlogic::ActsAsAuthentic::Login::Config (authlogic 2.1.3)
validates_uniqueness_of_login_field_options= public instance Authlogic::ActsAsAuthentic::Login::Config (authlogic 2.1.3)

Public Instance Methods

find_by_smart_case_login_field

(login)
authlogic 2.1.3

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.

login_field

(value = nil)
authlogic 2.1.3

The name of the login field in the database.

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

login_field=

(value = nil)
authlogic 2.1.3

Alias for login_field

merge_validates_format_of_login_field_options

(options = {})
authlogic 2.1.3

See merge_validates_length_of_login_field_options. The same thing, except for validates_format_of_login_field_options

merge_validates_length_of_login_field_options

(options = {})
authlogic 2.1.3

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

merge_validates_uniqueness_of_login_field_options

(options = {})
authlogic 2.1.3

See merge_validates_length_of_login_field_options. The same thing, except for validates_uniqueness_of_login_field_options

validate_login_field

(value = nil)
authlogic 2.1.3

Whether or not the validate the login field

  • Default: true
  • Accepts: Boolean

validate_login_field=

(value = nil)
authlogic 2.1.3

validates_format_of_login_field_options

(value = nil)
authlogic 2.1.3

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

validates_format_of_login_field_options=

(value = nil)
authlogic 2.1.3

validates_length_of_login_field_options

(value = nil)
authlogic 2.1.3

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

validates_length_of_login_field_options=

(value = nil)
authlogic 2.1.3

validates_uniqueness_of_login_field_options

(value = nil)
authlogic 2.1.3

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

validates_uniqueness_of_login_field_options=

(value = nil)
authlogic 2.1.3

Private Instance Methods

find_with_case

(field, value, sensitivity = true)
authlogic 2.1.3

Source Files

lib/authlogic/acts_as_authentic/login.rb