Permalink
Browse files

Persis BCrypt password during SHA1 migration

A full description of the issue this resolves is here:

#236
  • Loading branch information...
1 parent ada0433 commit f529a1a8b686ada90882f0f88292f1e4eeb11e5e @edouard edouard committed with croaky Nov 15, 2012
View
1 lib/clearance/password_strategies/bcrypt_migration_from_sha1.rb
@@ -44,6 +44,7 @@ def authenticated_with_sha1?(password)
if sha1_password?
if SHA1User.new(self).authenticated? password
self.password = password
+ self.save
true
end
end
View
6 spec/models/bcrypt_migration_from_sha1_spec.rb
@@ -45,6 +45,7 @@
before do
subject.salt = salt
subject.encrypted_password = sha1_hash
+ subject.stubs :save => true
end
it 'is authenticated' do
@@ -61,6 +62,11 @@
subject.authenticated? 'bad' + password
}.should_not raise_error(BCrypt::Errors::InvalidHash)
end
+
+ it 'saves the subject to database' do
+ subject.authenticated? password
+ subject.should have_received(:save)
+ end
end
context 'with a BCrypt-encrypted password' do

0 comments on commit f529a1a

Please sign in to comment.