diff --git a/lib/devise/models/database_authenticatable.rb b/lib/devise/models/database_authenticatable.rb index e16b7d845..d7df5e49e 100644 --- a/lib/devise/models/database_authenticatable.rb +++ b/lib/devise/models/database_authenticatable.rb @@ -37,6 +37,8 @@ module DatabaseAuthenticatable attr_reader :password, :current_password attr_accessor :password_confirmation + + alias_attribute :password_hash, :encrypted_password end def initialize(*args, &block) diff --git a/test/models/database_authenticatable_test.rb b/test/models/database_authenticatable_test.rb index 909e01045..16c2119df 100644 --- a/test/models/database_authenticatable_test.rb +++ b/test/models/database_authenticatable_test.rb @@ -106,6 +106,12 @@ def setup assert_present user.encrypted_password end + + test 'should have a password_hash as an alias to encrypted_password' do + user = new_user + assert_equal user.encrypted_password, user.password_hash + end + test 'should support custom hashing methods' do user = UserWithCustomHashing.new(password: '654321') assert_equal '123456', user.encrypted_password