regenerate confirmation token on reconfirmation, closes #1530

This commit is contained in:
Vasiliy Ermolovich 2011-12-31 14:22:58 +03:00
parent f712d07b23
commit aca8d3f34c
2 changed files with 11 additions and 0 deletions

View File

@ -68,7 +68,9 @@ module Devise
# Send confirmation instructions by email
def send_confirmation_instructions
self.confirmation_token = nil if reconfirmation_required?
@reconfirmation_required = false
generate_confirmation_token! if self.confirmation_token.blank?
self.devise_mailer.confirmation_instructions(self).deliver
end

View File

@ -252,6 +252,15 @@ class ReconfirmableTest < ActiveSupport::TestCase
assert_not_nil admin.confirmation_token
end
test 'should regenerate confirmation token after changing email' do
admin = create_admin
assert admin.confirm!
assert admin.update_attributes(:email => 'old_test@example.com')
token = admin.confirmation_token
assert admin.update_attributes(:email => 'new_test@example.com')
assert_not_equal token, admin.confirmation_token
end
test 'should send confirmation instructions by email after changing email' do
admin = create_admin
assert admin.confirm!