mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Save confirmation token to the database, if one does not exist but was requested, closes #377
This commit is contained in:
parent
4f6113ab68
commit
b4794e041b
2 changed files with 6 additions and 2 deletions
|
@ -50,7 +50,7 @@ module Devise
|
|||
|
||||
# Send confirmation instructions by email
|
||||
def send_confirmation_instructions
|
||||
generate_confirmation_token if self.confirmation_token.nil?
|
||||
generate_confirmation_token! if self.confirmation_token.nil?
|
||||
::Devise.mailer.confirmation_instructions(self).deliver
|
||||
end
|
||||
|
||||
|
@ -127,6 +127,10 @@ module Devise
|
|||
self.confirmation_sent_at = Time.now.utc
|
||||
end
|
||||
|
||||
def generate_confirmation_token!
|
||||
generate_confirmation_token && save(:validate => false)
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
# Attempt to find a user by it's email. If a record is found, send new
|
||||
# confirmation instructions to it. If not user is found, returns a new user
|
||||
|
|
|
@ -133,7 +133,7 @@ class ConfirmableTest < ActiveSupport::TestCase
|
|||
user.instance_eval { def confirmation_required?; false end }
|
||||
user.save
|
||||
user.send_confirmation_instructions
|
||||
assert_not_nil user.confirmation_token
|
||||
assert_not_nil user.reload.confirmation_token
|
||||
end
|
||||
|
||||
test 'should not resend email instructions if the user change his email' do
|
||||
|
|
Loading…
Reference in a new issue