Module: Authentication::Logic::ActsAsAuthentic::Password::Methods::InstanceMethods
- Defined in:
- lib/auth/logic/acts_as_authentic/password.rb
Overview
:nodoc:
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.
Instance Method Details
#password ⇒ Object
The password
191 192 193 194 195 |
# File 'lib/auth/logic/acts_as_authentic/password.rb', line 191 def password return nil unless defined?(@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.
199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/auth/logic/acts_as_authentic/password.rb', line 199 def password=(pass) return if ignore_blank_passwords? && pass.blank? run_callbacks :password_set do @password = pass send("#{password_salt_field}=", Authentication::Logic::Random.friendly_token) if password_salt_field send( "#{crypted_password_field}=", crypto_provider.encrypt(*encrypt_arguments(@password, false)) ) @password_changed = true end end |
#reset_password ⇒ Object Also known as: randomize_password
Resets the password to a random friendly token.
247 248 249 250 251 |
# File 'lib/auth/logic/acts_as_authentic/password.rb', line 247 def reset_password friendly_token = Authentication::Logic::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.
255 256 257 258 |
# File 'lib/auth/logic/acts_as_authentic/password.rb', line 255 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.
-
attempted_password [String] - password entered by user
-
check_against_database [boolean] - Should we check the password against the value in the database or the value in the object? Default taken from config option check_passwords_against_database. See config method for more information.
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/auth/logic/acts_as_authentic/password.rb', line 220 def valid_password?( attempted_password, check_against_database = check_passwords_against_database? ) crypted = crypted_password_to_validate_against(check_against_database) return false if attempted_password.blank? || crypted.blank? run_callbacks :password_verification do crypto_providers.each_with_index.any? do |encryptor, index| if encryptor_matches?( crypted, encryptor, attempted_password, check_against_database ) if transition_password?(index, encryptor, check_against_database) transition_password(attempted_password) end true else false end end end end |