mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Restored the ability to clear the password with user.password= nil (see the docs)
This commit is contained in:
parent
19a4ef305d
commit
20490adcbf
1 changed files with 3 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue