mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-10 08:08:00 -05:00
regenerate confirmation token on reconfirmation, closes #1530
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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!
|
||||
|
||||
Reference in New Issue
Block a user