1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

Add skip_reconfirmation! , closes #1708

This commit is contained in:
José Valim 2012-03-09 18:12:30 +01:00
parent b928b8b3a2
commit 0ab28ef8ee
2 changed files with 16 additions and 1 deletions

View file

@ -54,7 +54,7 @@ module Devise
self.confirmed_at = Time.now.utc self.confirmed_at = Time.now.utc
if self.class.reconfirmable && unconfirmed_email.present? if self.class.reconfirmable && unconfirmed_email.present?
@bypass_postpone = true skip_reconfirmation!
self.email = unconfirmed_email self.email = unconfirmed_email
self.unconfirmed_email = nil self.unconfirmed_email = nil
@ -108,6 +108,12 @@ module Devise
self.confirmed_at = Time.now.utc self.confirmed_at = Time.now.utc
end end
# If you don't want reconfirmation to be sent, neither a code
# to be generated, call skip_reconfirmation!
def skip_reconfirmation!
@bypass_postpone = true
end
def headers_for(action) def headers_for(action)
headers = super headers = super
if action == :confirmation_instructions && pending_reconfirmation? if action == :confirmation_instructions && pending_reconfirmation?

View file

@ -252,6 +252,15 @@ class ReconfirmableTest < ActiveSupport::TestCase
assert_not_nil admin.confirmation_token assert_not_nil admin.confirmation_token
end end
test 'should not generate confirmation token if skipping reconfirmation after changing email' do
admin = create_admin
assert admin.confirm!
admin.skip_reconfirmation!
assert admin.update_attributes(:email => 'new_test@example.com')
assert_nil admin.confirmation_token
end
test 'should regenerate confirmation token after changing email' do test 'should regenerate confirmation token after changing email' do
admin = create_admin admin = create_admin
assert admin.confirm! assert admin.confirm!