Module: Authlogic::Session::Password::InstanceMethods

Defined in:
lib/authlogic/session/password.rb

Overview

Password related instance methods

Instance Method Summary collapse

Instance Method Details

#credentialsObject

Returns the login_field / password_field credentials combination in hash form.



143
144
145
146
147
148
149
150
151
152
# File 'lib/authlogic/session/password.rb', line 143

def credentials
  if authenticating_with_password?
    details = {}
    details[.to_sym] = send()
    details[password_field.to_sym] = "<protected>"
    details
  else
    super
  end
end

#credentials=(value) ⇒ Object

Accepts the login_field / password_field credentials combination in hash form.

You must pass an actual Hash, ‘ActionController::Parameters` is specifically not allowed.

See ‘Authlogic::Session::Foundation#credentials=` for an overview of all method signatures.



162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/authlogic/session/password.rb', line 162

def credentials=(value)
  super
  values = Array.wrap(value)
  if values.first.is_a?(Hash)
    sliced = values
      .first
      .with_indifferent_access
      .slice(, password_field)
    sliced.each do |field, val|
      next if val.blank?
      send("#{field}=", val)
    end
  end
end

#initialize(*args) ⇒ Object



132
133
134
135
136
137
138
139
# File 'lib/authlogic/session/password.rb', line 132

def initialize(*args)
  unless self.class.configured_password_methods
    configure_password_methods
    self.class.configured_password_methods = true
  end
  instance_variable_set("@#{password_field}", nil)
  super
end

#invalid_password?Boolean

Returns:

  • (Boolean)


177
178
179
# File 'lib/authlogic/session/password.rb', line 177

def invalid_password?
  invalid_password == true
end