From 90c33a4e05a9fff70f6468654f7f58ef6b9b4b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 16 Dec 2009 17:34:09 +0100 Subject: [PATCH] Revert earlier commit. Do care about blank passwords, otherwise update_with_password is useless. --- CHANGELOG.rdoc | 1 - lib/devise/models/authenticatable.rb | 8 -------- test/models/authenticatable_test.rb | 7 ------- 3 files changed, 16 deletions(-) diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc index 6d8c6cc6..f0892e03 100644 --- a/CHANGELOG.rdoc +++ b/CHANGELOG.rdoc @@ -4,7 +4,6 @@ * Give scope to the proper model validation * enhancements - * Do not care about blank passwords on update * Mail views are scoped as well * Added update_with_password for authenticatable * Allow render_with_scope to accept :controller option diff --git a/lib/devise/models/authenticatable.rb b/lib/devise/models/authenticatable.rb index 46442ea7..9cb89ba1 100644 --- a/lib/devise/models/authenticatable.rb +++ b/lib/devise/models/authenticatable.rb @@ -78,14 +78,6 @@ module Devise end end - # Overwrite update_attributes to not care for blank passwords. - def update_attributes(attributes) - [:password, :password_confirmation].each do |k| - attributes.delete(k) unless attributes[k].present? - end - super - end - protected # Digests the password using the configured encryptor. diff --git a/test/models/authenticatable_test.rb b/test/models/authenticatable_test.rb index 24cf493a..685ce513 100644 --- a/test/models/authenticatable_test.rb +++ b/test/models/authenticatable_test.rb @@ -27,13 +27,6 @@ class AuthenticatableTest < ActiveSupport::TestCase assert_equal salt, user.password_salt end - test 'should not care about empty password on update' do - user = create_user - user.update_attributes(:email => "jose.valim+updated@gmail.com", :password => "") - user.reload - assert_equal user.email, "jose.valim+updated@gmail.com" - end - test 'should generate a base64 hash using SecureRandom for password salt' do ActiveSupport::SecureRandom.expects(:base64).with(15).returns('friendly_token') assert_equal 'friendly_token', new_user.password_salt