Permalink
Browse files

Restored the ability to clear the password with user.password= nil (s…

…ee the docs)
  • Loading branch information...
1 parent 19a4ef3 commit 20490adcbf00cd382e8e310415955a427b93e398 @chancancode chancancode committed Jan 20, 2014
Showing with 3 additions and 1 deletion.
  1. +3 −1 activemodel/lib/active_model/secure_password.rb
@@ -100,7 +100,9 @@ def authenticate(unencrypted_password)
# user.password = 'mUc3m00RsqyRe'
# user.password_digest # => "$2a$10$4LEA7r4YmNHtvlAvHhsYAeZmk/xeUVtMTYqwIvYY76EW5GUqDiP4."
def password=(unencrypted_password)
- unless unencrypted_password.blank?
+ if unencrypted_password.nil?
+ self.password_digest = nil
+ elsif unencrypted_password.present?
@password = unencrypted_password
cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST : BCrypt::Engine.cost
self.password_digest = BCrypt::Password.create(unencrypted_password, cost: cost)

0 comments on commit 20490ad

Please sign in to comment.