From b191afcb5bb19e11b340a5092b3205ac67b4e4a7 Mon Sep 17 00:00:00 2001
From: Eugen Rochko <eugen@zeonfederated.com>
Date: Fri, 23 Dec 2016 00:43:03 +0100
Subject: [PATCH] Fix confirmation email being sent to old address when
 changing it

---
 app/assets/javascripts/components/locales/en.jsx | 1 +
 app/mailers/user_mailer.rb                       | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/app/assets/javascripts/components/locales/en.jsx b/app/assets/javascripts/components/locales/en.jsx
index ddd7dd0c8..50007a7da 100644
--- a/app/assets/javascripts/components/locales/en.jsx
+++ b/app/assets/javascripts/components/locales/en.jsx
@@ -22,6 +22,7 @@ const en = {
   "account.follows": "Follows",
   "account.followers": "Followers",
   "account.follows_you": "Follows you",
+  "account.requested": "Awaiting approval",
   "getting_started.heading": "Getting started",
   "getting_started.about_addressing": "You can follow people if you know their username and the domain they are on by entering an e-mail-esque address into the search form.",
   "getting_started.about_shortcuts": "If the target user is on the same domain as you, just the username will work. The same rule applies to mentioning people in statuses.",
diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb
index e3ca39b3a..3b4d4d076 100644
--- a/app/mailers/user_mailer.rb
+++ b/app/mailers/user_mailer.rb
@@ -9,7 +9,7 @@ class UserMailer < Devise::Mailer
     @token    = token
 
     I18n.with_locale(@resource.locale || I18n.default_locale) do
-      mail to: @resource.email
+      mail to: @resource.unconfirmed_email.blank? ? @resource.email : @resource.unconfirmed_email
     end
   end