mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
update_with_password doesn't change encrypted password when it is invalid
closes #2130
This commit is contained in:
parent
5d311e7557
commit
10235f9d72
2 changed files with 8 additions and 0 deletions
|
@ -64,6 +64,7 @@ module Devise
|
|||
result = if valid_password?(current_password)
|
||||
update_attributes(params, *options)
|
||||
else
|
||||
params.delete(:password)
|
||||
self.assign_attributes(params, *options)
|
||||
self.valid?
|
||||
self.errors.add(:current_password, current_password.blank? ? :blank : :invalid)
|
||||
|
|
|
@ -108,6 +108,13 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
|||
assert_match "is invalid", user.errors[:current_password].join
|
||||
end
|
||||
|
||||
test 'should not change encrypted password when it is invalid' do
|
||||
user = create_user
|
||||
assert_not user.update_with_password(:current_password => 'other',
|
||||
:password => 'pass4321', :password_confirmation => 'pass4321')
|
||||
assert_not user.encrypted_password_changed?
|
||||
end
|
||||
|
||||
test 'should add an error to current password when it is blank' do
|
||||
user = create_user
|
||||
assert_not user.update_with_password(:password => 'pass4321',
|
||||
|
|
Loading…
Reference in a new issue