Module: Authlogic::ActsAsAuthentic::Password::Methods::InstanceMethods
- Defined in:
- lib/authlogic/acts_as_authentic/password.rb
Instance Method Summary collapse
-
#password ⇒ Object
The password.
-
#password=(pass) ⇒ Object
This is a virtual method.
-
#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
#password ⇒ Object
The password
265 266 267 |
# File 'lib/authlogic/acts_as_authentic/password.rb', line 265 def password @password end |
#password=(pass) ⇒ Object
This is a virtual method. Once a password is passed to it, it will create new password salt as well as encrypt the password.
271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/authlogic/acts_as_authentic/password.rb', line 271 def password=(pass) return if ignore_blank_passwords? && pass.blank? before_password_set @password = pass send("#{password_salt_field}=", Authlogic::Random.friendly_token) if password_salt_field encryptor_arguments_type = act_like_restful_authentication? ? :restful_authentication : nil send( "#{crypted_password_field}=", crypto_provider.encrypt(*encrypt_arguments(@password, false, encryptor_arguments_type)) ) @password_changed = true after_password_set end |
#reset_password ⇒ Object Also known as: randomize_password
Resets the password to a random friendly token.
315 316 317 318 319 |
# File 'lib/authlogic/acts_as_authentic/password.rb', line 315 def reset_password friendly_token = Authlogic::Random.friendly_token self.password = friendly_token self.password_confirmation = friendly_token if self.class.require_password_confirmation end |
#reset_password! ⇒ Object Also known as: randomize_password!
Resets the password to a random friendly token and then saves the record.
323 324 325 326 |
# File 'lib/authlogic/acts_as_authentic/password.rb', line 323 def reset_password! reset_password save_without_session_maintenance(:validate => 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 more information, but basically it just tells Authlogic to check the password against the value in the database or the value in the object.
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
# File 'lib/authlogic/acts_as_authentic/password.rb', line 290 def valid_password?(attempted_password, check_against_database = check_passwords_against_database?) crypted = if check_against_database && send("#{crypted_password_field}_changed?") send("#{crypted_password_field}_was") else send(crypted_password_field) end return false if attempted_password.blank? || crypted.blank? before_password_verification crypto_providers.each_with_index do |encryptor, index| if encryptor_matches?(crypted, encryptor, index, attempted_password, check_against_database) if transition_password?(index, encryptor, crypted, check_against_database) transition_password(attempted_password) end after_password_verification return true end end false end |