diff options
author | Godfrey Chan <godfreykfc@gmail.com> | 2014-01-20 04:27:42 -0800 |
---|---|---|
committer | Godfrey Chan <godfreykfc@gmail.com> | 2014-01-24 19:49:30 -0800 |
commit | 20490adcbf00cd382e8e310415955a427b93e398 (patch) | |
tree | 507f190c9dc91eb8249321c477efd9552ad696f1 /activemodel | |
parent | 19a4ef305d84f4aad633c25f850967bbc375da84 (diff) | |
download | rails-20490adcbf00cd382e8e310415955a427b93e398.tar.gz rails-20490adcbf00cd382e8e310415955a427b93e398.tar.bz2 rails-20490adcbf00cd382e8e310415955a427b93e398.zip |
Restored the ability to clear the password with user.password= nil (see the docs)
Diffstat (limited to 'activemodel')
-rw-r--r-- | activemodel/lib/active_model/secure_password.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/secure_password.rb b/activemodel/lib/active_model/secure_password.rb index d824a66784..e4af1efa65 100644 --- a/activemodel/lib/active_model/secure_password.rb +++ b/activemodel/lib/active_model/secure_password.rb @@ -100,7 +100,9 @@ module ActiveModel # 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) |