mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Send on create confirmation email after commit (#4064)
Call send_on_create_confirmation_instructions in after_commit instead of after_create, I think this is no harm in general and it makes things like async job work. Fix #4062
This commit is contained in:
parent
1ff64fbbd3
commit
78bbf6dcc4
8 changed files with 26 additions and 7 deletions
1
Gemfile
1
Gemfile
|
@ -12,6 +12,7 @@ group :test do
|
|||
gem "omniauth-openid", "~> 1.0.1"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.1", require: false
|
||||
gem 'test_after_commit', require: false
|
||||
end
|
||||
|
||||
platforms :jruby do
|
||||
|
|
|
@ -145,6 +145,8 @@ GEM
|
|||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.11)
|
||||
test_after_commit (1.0.0)
|
||||
activerecord (>= 3.2)
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.5)
|
||||
tzinfo (1.2.2)
|
||||
|
@ -173,6 +175,7 @@ DEPENDENCIES
|
|||
rails (~> 4.2.6)
|
||||
rdoc
|
||||
sqlite3
|
||||
test_after_commit
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
|
|
|
@ -12,6 +12,7 @@ group :test do
|
|||
gem "omniauth-openid", "~> 1.0.1"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.1", require: false
|
||||
gem 'test_after_commit', require: false
|
||||
end
|
||||
|
||||
platforms :jruby do
|
||||
|
|
|
@ -48,7 +48,7 @@ GIT
|
|||
PATH
|
||||
remote: ..
|
||||
specs:
|
||||
devise (4.0.0.rc2)
|
||||
devise (4.0.1)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0, < 5.1)
|
||||
|
@ -133,6 +133,8 @@ GEM
|
|||
activesupport (>= 3.0)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
sqlite3 (1.3.11)
|
||||
test_after_commit (1.0.0)
|
||||
activerecord (>= 3.2)
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.5)
|
||||
tzinfo (1.2.2)
|
||||
|
@ -161,6 +163,7 @@ DEPENDENCIES
|
|||
rails!
|
||||
rdoc
|
||||
sqlite3
|
||||
test_after_commit
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
|
|
|
@ -12,6 +12,7 @@ group :test do
|
|||
gem "omniauth-openid", "~> 1.0.1"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.1", require: false
|
||||
gem 'test_after_commit', require: false
|
||||
end
|
||||
|
||||
platforms :jruby do
|
||||
|
|
|
@ -58,7 +58,7 @@ GIT
|
|||
PATH
|
||||
remote: ..
|
||||
specs:
|
||||
devise (4.0.0.rc2)
|
||||
devise (4.0.1)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0, < 5.1)
|
||||
|
@ -144,7 +144,7 @@ GEM
|
|||
rake (11.0.1)
|
||||
rdoc (4.2.2)
|
||||
json (~> 1.4)
|
||||
responders (2.1.1)
|
||||
responders (2.1.2)
|
||||
railties (>= 4.2.0, < 5.1)
|
||||
ruby-openid (2.7.0)
|
||||
sprockets (3.5.2)
|
||||
|
@ -155,6 +155,8 @@ GEM
|
|||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.11)
|
||||
test_after_commit (1.0.0)
|
||||
activerecord (>= 3.2)
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.5)
|
||||
tzinfo (1.2.2)
|
||||
|
@ -183,6 +185,7 @@ DEPENDENCIES
|
|||
rails!
|
||||
rdoc
|
||||
sqlite3
|
||||
test_after_commit
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
|
|
|
@ -43,9 +43,15 @@ module Devise
|
|||
|
||||
included do
|
||||
before_create :generate_confirmation_token, if: :confirmation_required?
|
||||
after_create :send_on_create_confirmation_instructions, if: :send_confirmation_notification?
|
||||
after_create :skip_reconfirmation!, if: :send_confirmation_notification?
|
||||
if respond_to?(:after_commit) # ActiveRecord
|
||||
after_commit :send_on_create_confirmation_instructions, on: :create, if: :send_confirmation_notification?
|
||||
after_commit :send_reconfirmation_instructions, on: :update, if: :reconfirmation_required?
|
||||
else # Mongoid
|
||||
after_create :send_on_create_confirmation_instructions, if: :send_confirmation_notification?
|
||||
after_update :send_reconfirmation_instructions, if: :reconfirmation_required?
|
||||
end
|
||||
before_update :postpone_email_change_until_confirmation_and_regenerate_confirmation_token, if: :postpone_email_change?
|
||||
after_update :send_reconfirmation_instructions, if: :reconfirmation_required?
|
||||
end
|
||||
|
||||
def initialize(*args, &block)
|
||||
|
@ -169,7 +175,6 @@ module Devise
|
|||
# in models to map to a nice sign up e-mail.
|
||||
def send_on_create_confirmation_instructions
|
||||
send_confirmation_instructions
|
||||
skip_reconfirmation!
|
||||
end
|
||||
|
||||
# Callback to overwrite if confirmation is required or not.
|
||||
|
|
|
@ -5,9 +5,11 @@ ActiveRecord::Base.include_root_in_json = true
|
|||
ActiveRecord::Migrator.migrate(File.expand_path("../../rails_app/db/migrate/", __FILE__))
|
||||
|
||||
class ActiveSupport::TestCase
|
||||
if Rails.version >= '5.0.0'
|
||||
if Devise.rails5?
|
||||
self.use_transactional_tests = true
|
||||
else
|
||||
# Let `after_commit` work with transactional fixtures, however this is not needed for Rails 5.
|
||||
require 'test_after_commit'
|
||||
self.use_transactional_fixtures = true
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue