From 86afa6f4132e9f803d27edbd2a9e8f07eba3f7ab Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Wed, 24 Jun 2020 21:28:40 +0100 Subject: [PATCH] Adapt to devise 3.2 and use after_confirmation callback to send welcome email --- app/models/spree/user.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/models/spree/user.rb b/app/models/spree/user.rb index d14694de9b..da276ec936 100644 --- a/app/models/spree/user.rb +++ b/app/models/spree/user.rb @@ -34,10 +34,6 @@ module Spree # We use the same options as Spree and add :confirmable devise :confirmable, reconfirmable: true - # TODO: Later versions of devise have a dedicated after_confirmation callback, so use that - after_update :welcome_after_confirm, if: lambda { - confirmation_token_changed? && confirmation_token.nil? - } class DestroyWithOrdersError < StandardError; end @@ -82,9 +78,9 @@ module Spree customers.find_by(enterprise_id: enterprise) end - def welcome_after_confirm - # Send welcome email if we are confirming an user's email - # Note: this callback only runs on email confirmation + # This is a Devise Confirmable callback that runs on email confirmation + # It sends a welcome email after the user email is confirmed + def after_confirmation return unless confirmed? && unconfirmed_email.nil? && !unconfirmed_email_changed? send_signup_confirmation