module Authlogic::Session::Password::InstanceMethods

Password related instance methods

Public Class Methods

new(*args) click to toggle source
# File lib/authlogic/session/password.rb, line 116
        def initialize(*args)
          if !self.class.configured_password_methods
            if login_field
              self.class.send(:attr_writer, login_field) if !respond_to?("#{login_field}=")
              self.class.send(:attr_reader, login_field) if !respond_to?(login_field)
            end
            
            if password_field
              self.class.send(:attr_writer, password_field) if !respond_to?("#{password_field}=")
              self.class.send(:define_method, password_field) {} if !respond_to?(password_field)

              self.class.class_eval "                private
                  # The password should not be accessible publicly. This way forms using form_for don't fill the password with the
                  # attempted password. To prevent this we just create this method that is private.
                  def protected_#{password_field}
                    @#{password_field}
                  end
", __FILE__, __LINE__
            end

            self.class.configured_password_methods = true
          end
          
          super
        end

Public Instance Methods

credentials() click to toggle source

Returns the login_field / password_field credentials combination in hash form.

# File lib/authlogic/session/password.rb, line 144
def credentials
  if authenticating_with_password?
    details = {}
    details[login_field.to_sym] = send(login_field)
    details[password_field.to_sym] = "<protected>"
    details
  else
    super
  end
end
credentials=(value) click to toggle source

Accepts the login_field / password_field credentials combination in hash form.

# File lib/authlogic/session/password.rb, line 156
def credentials=(value)
  super
  values = value.is_a?(Array) ? value : [value]
  if values.first.is_a?(Hash)
    values.first.with_indifferent_access.slice(login_field, password_field).each do |field, value|
      next if value.blank?
      send("#{field}=", value)
    end
  end
end
invalid_password?() click to toggle source
# File lib/authlogic/session/password.rb, line 167
def invalid_password?
  invalid_password == true
end