Module: Authlogic::ActsAsAuthentic::Password::Methods::InstanceMethods
- Defined in:
- lib/authlogic/acts_as_authentic/password.rb
Instance Method Summary collapse
-
#reset_password ⇒ Object
(also: #randomize_password)
Resets the password to a random friendly token.
-
#reset_password! ⇒ Object
(also: #randomize_password!)
Resets the password to a random friendly token and then saves the record.
-
#valid_password?(attempted_password, check_against_database = check_passwords_against_database?) ) ⇒ Boolean
Accepts a raw password to determine if it is the correct password or not.
Instance Method Details
#reset_password ⇒ Object Also known as: randomize_password
Resets the password to a random friendly token.
296 297 298 299 300 |
# File 'lib/authlogic/acts_as_authentic/password.rb', line 296 def reset_password friendly_token = Authlogic::Random.friendly_token self.send("#{password_field}=", friendly_token) self.send("#{password_confirmation_field}=", friendly_token) end |
#reset_password! ⇒ Object Also known as: randomize_password!
Resets the password to a random friendly token and then saves the record.
304 305 306 307 |
# File 'lib/authlogic/acts_as_authentic/password.rb', line 304 def reset_password! reset_password save_without_session_maintenance(false) end |
#valid_password?(attempted_password, check_against_database = check_passwords_against_database?) ) ⇒ Boolean
Accepts a raw password to determine if it is the correct password or not. Notice the second argument. That defaults to the value of check_passwords_against_database. See that method for mor information, but basically it just tells Authlogic to check the password against the value in the database or the value in the object.
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/authlogic/acts_as_authentic/password.rb', line 273 def valid_password?(attempted_password, check_against_database = check_passwords_against_database?) crypted = check_against_database && send("#{crypted_password_field}_changed?") ? send("#{crypted_password_field}_was") : send(crypted_password_field) return false if attempted_password.blank? || crypted.blank? before_password_verification crypto_providers.each_with_index do |encryptor, index| # The arguments_type of for the transitioning from restful_authentication arguments_type = (act_like_restful_authentication? && index == 0) || (transition_from_restful_authentication? && index > 0 && encryptor == Authlogic::CryptoProviders::Sha1) ? :restful_authentication : nil arguments_type = :salt_first if salt_first? if encryptor.matches?(crypted, *encrypt_arguments(attempted_password, check_against_database, arguments_type)) transition_password(attempted_password) if transition_password?(index, encryptor, crypted, check_against_database) after_password_verification return true end end false end |