mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
regenerate confirmation token on reconfirmation, closes #1530
This commit is contained in:
parent
f712d07b23
commit
aca8d3f34c
2 changed files with 11 additions and 0 deletions
|
@ -68,7 +68,9 @@ module Devise
|
||||||
|
|
||||||
# Send confirmation instructions by email
|
# Send confirmation instructions by email
|
||||||
def send_confirmation_instructions
|
def send_confirmation_instructions
|
||||||
|
self.confirmation_token = nil if reconfirmation_required?
|
||||||
@reconfirmation_required = false
|
@reconfirmation_required = false
|
||||||
|
|
||||||
generate_confirmation_token! if self.confirmation_token.blank?
|
generate_confirmation_token! if self.confirmation_token.blank?
|
||||||
self.devise_mailer.confirmation_instructions(self).deliver
|
self.devise_mailer.confirmation_instructions(self).deliver
|
||||||
end
|
end
|
||||||
|
|
|
@ -252,6 +252,15 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
||||||
assert_not_nil admin.confirmation_token
|
assert_not_nil admin.confirmation_token
|
||||||
end
|
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
|
test 'should send confirmation instructions by email after changing email' do
|
||||||
admin = create_admin
|
admin = create_admin
|
||||||
assert admin.confirm!
|
assert admin.confirm!
|
||||||
|
|
Loading…
Reference in a new issue