You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2020/06/02 17:03:59 UTC

[allura] branch master updated (59863ea -> 992db64)

This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git.


    from 59863ea  Add more functionality to the add_user_to_group.py script
     new 5df2588  email_change_notif email added/removed mail notifications
     new 522e634  email_change_notif email on primary changed, password recover, email verified
     new 992db64  email_change_notif prevent new email notifications on site-admin

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 Allura/allura/controllers/auth.py                  | 33 ++++++++++++++++++-
 .../mail/{password_changed.md => email_added.md}   |  4 ++-
 .../mail/{password_changed.md => email_removed.md} |  4 ++-
 ...assword_changed.md => primary_email_changed.md} |  4 ++-
 Allura/allura/tests/functional/test_auth.py        | 38 ++++++++++++++++++----
 5 files changed, 73 insertions(+), 10 deletions(-)
 copy Allura/allura/templates/mail/{password_changed.md => email_added.md} (87%)
 copy Allura/allura/templates/mail/{password_changed.md => email_removed.md} (87%)
 copy Allura/allura/templates/mail/{password_changed.md => primary_email_changed.md} (87%)


[allura] 01/03: email_change_notif email added/removed mail notifications

Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 5df2588e768c41560c54504f8af88cf7e53e15a3
Author: Dillon Walls <di...@slashdotmedia.com>
AuthorDate: Wed May 20 22:42:29 2020 +0000

    email_change_notif email added/removed mail notifications
---
 Allura/allura/controllers/auth.py             | 11 +++++++++++
 Allura/allura/templates/mail/email_added.md   | 26 ++++++++++++++++++++++++++
 Allura/allura/templates/mail/email_removed.md | 26 ++++++++++++++++++++++++++
 Allura/allura/tests/functional/test_auth.py   | 15 ++++++++++++++-
 4 files changed, 77 insertions(+), 1 deletion(-)

diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index f8dff10..a803533 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -554,6 +554,7 @@ class PreferencesController(BaseController):
         addr = kw.pop('addr', None)
         new_addr = kw.pop('new_addr', None)
         primary_addr = kw.pop('primary_addr', None)
+        notify_addr = primary_addr
         provider = plugin.AuthenticationProvider.get(request)
         for i, (old_a, data) in enumerate(zip(user.email_addresses, addr or [])):
             obj = user.address_object(old_a)
@@ -572,6 +573,11 @@ class PreferencesController(BaseController):
                         primary_addr = None
                         user.set_tool_data('AuthPasswordReset', hash='', hash_expiry='')
                 h.auditlog_user('Email address deleted: %s', user.email_addresses[i], user=user)
+                email_body = g.jinja2_env.get_template('allura:templates/mail/email_removed.md').render(dict(
+                    user=user,
+                    config=config,
+                ))
+                send_system_mail_to_user(notify_addr, 'Email Address Removed', email_body)
                 del user.email_addresses[i]
                 if obj:
                     obj.delete()
@@ -610,6 +616,11 @@ class PreferencesController(BaseController):
                         flash('A verification email has been sent.  Please check your email and click to confirm.')
 
                     h.auditlog_user('New email address: %s', new_addr['addr'], user=user)
+                    email_body = g.jinja2_env.get_template('allura:templates/mail/email_added.md').render(dict(
+                        user=user,
+                        config=config,
+                    ))
+                    send_system_mail_to_user(notify_addr, 'New Email Address Added', email_body)
                 else:
                     flash('Email address %s is invalid' % new_addr['addr'], 'error')
             else:
diff --git a/Allura/allura/templates/mail/email_added.md b/Allura/allura/templates/mail/email_added.md
new file mode 100644
index 0000000..b0ecc58
--- /dev/null
+++ b/Allura/allura/templates/mail/email_added.md
@@ -0,0 +1,26 @@
+{#
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+-#}
+
+Hello {{ user.display_name }},
+
+A new email address has been added to your {{ config['site_name'] }} account "{{ user.username }}". This is a confirmation email, you are all set.
+
+{% block footer %}
+If you did not do this, please contact us immediately.
+{% endblock %}
diff --git a/Allura/allura/templates/mail/email_removed.md b/Allura/allura/templates/mail/email_removed.md
new file mode 100644
index 0000000..6eb6a9f
--- /dev/null
+++ b/Allura/allura/templates/mail/email_removed.md
@@ -0,0 +1,26 @@
+{#
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+-#}
+
+Hello {{ user.display_name }},
+
+An email address has been removed from your {{ config['site_name'] }} account "{{ user.username }}". This is a confirmation email, you are all set.
+
+{% block footer %}
+If you did not do this, please contact us immediately.
+{% endblock %}
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index 3d922b6..9d92260 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -674,8 +674,10 @@ class TestAuth(TestController):
         user = M.User.by_username('test-admin')
         assert_not_equal(old_pass, user.get_pref('password'))
 
+    @patch('allura.tasks.mail_tasks.sendsimplemail')
+    @patch('allura.lib.helpers.gen_message_id')
     @td.with_user_project('test-admin')
-    def test_prefs(self):
+    def test_prefs(self, gen_message_id, sendsimplemail):
         r = self.app.get('/auth/preferences/',
                          extra_environ=dict(username=str('test-admin')))
         # check preconditions of test data
@@ -701,6 +703,11 @@ class TestAuth(TestController):
         user = M.User.query.get(username='test-admin')
         assert_equal(user.get_pref('email_address'), 'test-admin@users.localhost')
 
+        # assert 'email added' notification email sent
+        args, kwargs = sendsimplemail.post.call_args
+        assert_equal(kwargs['toaddr'], 'test-admin@users.localhost')
+        assert_equal(kwargs['subject'], 'New Email Address Added')
+
         # remove test-admin@users.localhost
         with td.audits('Email address deleted: test-admin@users.localhost', user=True):
             r = self.app.post('/auth/preferences/update_emails',
@@ -715,6 +722,12 @@ class TestAuth(TestController):
                                   'preferences.email_format': 'plain',
                                   '_session_id': self.app.cookies['_session_id'],
                               })
+
+        # assert 'remail removed' notification email sent
+        args, kwargs = sendsimplemail.post.call_args
+        assert_equal(kwargs['toaddr'], 'test-admin@users.localhost')
+        assert_equal(kwargs['subject'], 'Email Address Removed')
+
         r = self.app.get('/auth/preferences/')
         assert 'test-admin@users.localhost' not in r
         # preferred address has not changed if email is not verified


[allura] 02/03: email_change_notif email on primary changed, password recover, email verified

Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 522e6341a539e7f1abbf2725dc7f079ce7037787
Author: Dillon Walls <di...@slashdotmedia.com>
AuthorDate: Fri May 22 16:44:09 2020 +0000

    email_change_notif email on primary changed, password recover, email verified
---
 Allura/allura/controllers/auth.py                  | 30 +++++++++++++-----
 Allura/allura/templates/mail/email_added.md        |  4 ++-
 Allura/allura/templates/mail/email_removed.md      |  4 ++-
 .../{email_added.md => primary_email_changed.md}   |  4 ++-
 Allura/allura/tests/functional/test_auth.py        | 37 +++++++++++++++-------
 5 files changed, 56 insertions(+), 23 deletions(-)

diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index a803533..947ee19 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -198,6 +198,11 @@ class AuthController(BaseController):
         user.set_tool_data('AuthPasswordReset', hash='', hash_expiry='')  # Clear password reset token
         user.set_tool_data('allura', pwd_reset_preserve_session=session.id)
         h.auditlog_user('Password changed (through recovery process)', user=user)
+        email_body = g.jinja2_env.get_template('allura:templates/mail/password_changed.md').render(dict(
+            user=user,
+            config=config
+        ))
+        send_system_mail_to_user(user, 'Password Changed', email_body)
         flash('Password changed')
         redirect('/auth/?return_to=/')  # otherwise the default return_to would be the forgotten_password referrer page
 
@@ -306,6 +311,12 @@ class AuthController(BaseController):
                 projectname = plugin.AuthenticationProvider.get(request).user_project_shortname(user)
                 n = M.Neighborhood.query.get(name='Users')
                 n.register_project(projectname, user=user, user_project=True)
+            email_body = g.jinja2_env.get_template('allura:templates/mail/email_added.md').render(dict(
+                user=user,
+                config=config,
+                addr=addr.email
+            ))
+            send_system_mail_to_user(user, 'New Email Address Added', email_body)
         else:
             flash('Unknown verification link', 'error')
 
@@ -554,7 +565,7 @@ class PreferencesController(BaseController):
         addr = kw.pop('addr', None)
         new_addr = kw.pop('new_addr', None)
         primary_addr = kw.pop('primary_addr', None)
-        notify_addr = primary_addr
+        old_primary_addr = user.preferences.email_address
         provider = plugin.AuthenticationProvider.get(request)
         for i, (old_a, data) in enumerate(zip(user.email_addresses, addr or [])):
             obj = user.address_object(old_a)
@@ -576,8 +587,9 @@ class PreferencesController(BaseController):
                 email_body = g.jinja2_env.get_template('allura:templates/mail/email_removed.md').render(dict(
                     user=user,
                     config=config,
+                    addr=user.email_addresses[i]
                 ))
-                send_system_mail_to_user(notify_addr, 'Email Address Removed', email_body)
+                send_system_mail_to_user(user, 'Email Address Removed', email_body)
                 del user.email_addresses[i]
                 if obj:
                     obj.delete()
@@ -616,11 +628,6 @@ class PreferencesController(BaseController):
                         flash('A verification email has been sent.  Please check your email and click to confirm.')
 
                     h.auditlog_user('New email address: %s', new_addr['addr'], user=user)
-                    email_body = g.jinja2_env.get_template('allura:templates/mail/email_added.md').render(dict(
-                        user=user,
-                        config=config,
-                    ))
-                    send_system_mail_to_user(notify_addr, 'New Email Address Added', email_body)
                 else:
                     flash('Email address %s is invalid' % new_addr['addr'], 'error')
             else:
@@ -628,7 +635,7 @@ class PreferencesController(BaseController):
         if not primary_addr and not user.get_pref('email_address') and user.email_addresses:
             primary_addr = select_new_primary_addr(user)
         if primary_addr:
-            if user.get_pref('email_address') != primary_addr:
+            if old_primary_addr != primary_addr:
                 if not admin and (not kw.get('password') or not provider.validate_password(user, kw.get('password'))):
                     flash('You must provide your current password to change primary address', 'error')
                     return
@@ -637,6 +644,13 @@ class PreferencesController(BaseController):
                     user.get_pref('email_address'),
                     primary_addr,
                     user=user)
+                email_body = g.jinja2_env.get_template('allura:templates/mail/primary_email_changed.md').render(dict(
+                    user=user,
+                    config=config,
+                    addr=primary_addr
+                ))
+                # send to previous primary addr
+                send_system_mail_to_user(old_primary_addr, 'Primary Email Address Changed', email_body)
             user.set_pref('email_address', primary_addr)
             user.set_tool_data('AuthPasswordReset', hash='', hash_expiry='')
 
diff --git a/Allura/allura/templates/mail/email_added.md b/Allura/allura/templates/mail/email_added.md
index b0ecc58..eace718 100644
--- a/Allura/allura/templates/mail/email_added.md
+++ b/Allura/allura/templates/mail/email_added.md
@@ -19,7 +19,9 @@
 
 Hello {{ user.display_name }},
 
-A new email address has been added to your {{ config['site_name'] }} account "{{ user.username }}". This is a confirmation email, you are all set.
+A new email address was added to your {{ config['site_name'] }} account "{{ user.username }}":  
+
+* {{ addr }}
 
 {% block footer %}
 If you did not do this, please contact us immediately.
diff --git a/Allura/allura/templates/mail/email_removed.md b/Allura/allura/templates/mail/email_removed.md
index 6eb6a9f..323ea17 100644
--- a/Allura/allura/templates/mail/email_removed.md
+++ b/Allura/allura/templates/mail/email_removed.md
@@ -19,7 +19,9 @@
 
 Hello {{ user.display_name }},
 
-An email address has been removed from your {{ config['site_name'] }} account "{{ user.username }}". This is a confirmation email, you are all set.
+An email address was removed from your {{ config['site_name'] }} account "{{ user.username }}":  
+
+* {{ addr }} 
 
 {% block footer %}
 If you did not do this, please contact us immediately.
diff --git a/Allura/allura/templates/mail/email_added.md b/Allura/allura/templates/mail/primary_email_changed.md
similarity index 86%
copy from Allura/allura/templates/mail/email_added.md
copy to Allura/allura/templates/mail/primary_email_changed.md
index b0ecc58..2830b1c 100644
--- a/Allura/allura/templates/mail/email_added.md
+++ b/Allura/allura/templates/mail/primary_email_changed.md
@@ -19,7 +19,9 @@
 
 Hello {{ user.display_name }},
 
-A new email address has been added to your {{ config['site_name'] }} account "{{ user.username }}". This is a confirmation email, you are all set.
+The primary email address on your {{ config['site_name'] }} account "{{ user.username }}" was changed to:  
+
+* {{ addr }}
 
 {% block footer %}
 If you did not do this, please contact us immediately.
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index 9d92260..c85ca4a 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -371,7 +371,6 @@ class TestAuth(TestController):
                                                           'Please check your email and click to confirm.'
 
         args, kwargs = sendsimplemail.post.call_args
-
         assert sendsimplemail.post.call_count == 1
         assert kwargs['toaddr'] == email_address
         assert kwargs['subject'] == '%s - Email address claim attempt' % config['site_name']
@@ -511,7 +510,9 @@ class TestAuth(TestController):
         email = M.EmailAddress.find(dict(email=email_address, claimed_by_user_id=user._id)).first()
         assert not email.confirmed
 
-    def test_verify_addr_correct_session(self):
+    @patch('allura.tasks.mail_tasks.sendsimplemail')
+    @patch('allura.lib.helpers.gen_message_id')
+    def test_verify_addr_correct_session(self, gen_message_id, sendsimplemail):
         self.app.get('/').follow()  # establish session
         email_address = 'test_abcd@domain.net'
 
@@ -545,6 +546,11 @@ class TestAuth(TestController):
         assert_in('confirmed', json.loads(self.webflash(r))['message'])
         assert_equal('ok', json.loads(self.webflash(r))['status'])
 
+        # assert 'email added' notification email sent
+        args, kwargs = sendsimplemail.post.call_args
+        assert_equal(kwargs['toaddr'], user._id)
+        assert_equal(kwargs['subject'], 'New Email Address Added')
+
     @staticmethod
     def _create_password_reset_hash():
         """ Generates a password reset token for a given user.
@@ -703,11 +709,6 @@ class TestAuth(TestController):
         user = M.User.query.get(username='test-admin')
         assert_equal(user.get_pref('email_address'), 'test-admin@users.localhost')
 
-        # assert 'email added' notification email sent
-        args, kwargs = sendsimplemail.post.call_args
-        assert_equal(kwargs['toaddr'], 'test-admin@users.localhost')
-        assert_equal(kwargs['subject'], 'New Email Address Added')
-
         # remove test-admin@users.localhost
         with td.audits('Email address deleted: test-admin@users.localhost', user=True):
             r = self.app.post('/auth/preferences/update_emails',
@@ -723,9 +724,9 @@ class TestAuth(TestController):
                                   '_session_id': self.app.cookies['_session_id'],
                               })
 
-        # assert 'remail removed' notification email sent
+        # assert 'email_removed' notification email sent
         args, kwargs = sendsimplemail.post.call_args
-        assert_equal(kwargs['toaddr'], 'test-admin@users.localhost')
+        assert_equal(kwargs['toaddr'], user._id)
         assert_equal(kwargs['subject'], 'Email Address Removed')
 
         r = self.app.get('/auth/preferences/')
@@ -742,7 +743,9 @@ class TestAuth(TestController):
                               extra_environ=dict(username=str('test-admin')))
 
     @td.with_user_project('test-admin')
-    def test_email_prefs_change_requires_password(self):
+    @patch('allura.tasks.mail_tasks.sendsimplemail')
+    @patch('allura.lib.helpers.gen_message_id')
+    def test_email_prefs_change_requires_password(self, gen_message_id, sendsimplemail):
         self.app.get('/').follow()  # establish session
         # Claim new email
         new_email_params = {
@@ -798,6 +801,11 @@ class TestAuth(TestController):
         assert_not_in('You must provide your current password to change primary address', self.webflash(r))
         assert_equal(M.User.by_username('test-admin').get_pref('email_address'), 'test@example.com')
 
+        # assert 'email added' notification email sent using original primary addr
+        args, kwargs = sendsimplemail.post.call_args
+        assert_equal(kwargs['toaddr'], 'test-admin@users.localhost')
+        assert_equal(kwargs['subject'], 'Primary Email Address Changed')
+
         # Remove email
         remove_email_params = {
             'addr-1.ord': '1',
@@ -1601,7 +1609,7 @@ class TestPasswordReset(TestController):
 
     @patch('allura.tasks.mail_tasks.sendsimplemail')
     @patch('allura.lib.helpers.gen_message_id')
-    def test_password_reset(self, gen_message_id, sendmail):
+    def test_password_reset(self, gen_message_id, sendsimplemail):
         self.app.get('/').follow()  # establish session
         user = M.User.query.get(username='test-admin')
         email = M.EmailAddress.find({'claimed_by_user_id': user._id}).first()
@@ -1626,7 +1634,7 @@ class TestPasswordReset(TestController):
 To update your password on %s, please visit the following URL:
 
 %s/auth/forgotten_password/%s''' % (config['site_name'], config['base_url'], hash)
-        sendmail.post.assert_called_once_with(
+        sendsimplemail.post.assert_called_once_with(
             sender='noreply@localhost',
             toaddr=email.email,
             fromaddr='"{}" <{}>'.format(config['site_name'], config['forgemail.return_path']),
@@ -1645,6 +1653,11 @@ To update your password on %s, please visit the following URL:
         with td.audits('Password changed \(through recovery process\)', user=True):
             # escape parentheses, so they would not be treated as regex group
             r = form.submit()
+            
+        # verify 'Password Changed' email sent
+        args, kwargs = sendsimplemail.post.call_args
+        assert_equal(kwargs['toaddr'], user._id)
+        assert_equal(kwargs['subject'], 'Password Changed')
 
         # confirm password changed and works
         user = M.User.query.get(username='test-admin')


[allura] 03/03: email_change_notif prevent new email notifications on site-admin

Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 992db64a3975191f0352bf1ff3bd96599d233ed3
Author: Dillon Walls <di...@slashdotmedia.com>
AuthorDate: Wed May 27 15:01:02 2020 +0000

    email_change_notif prevent new email notifications on site-admin
---
 Allura/allura/controllers/auth.py | 44 ++++++++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 19 deletions(-)

diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 947ee19..9573993 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -301,6 +301,15 @@ class AuthController(BaseController):
                         return_to += '?' + request.environ['QUERY_STRING']
                     redirect(login_url, {'return_to': return_to})
 
+            if do_auth_check:
+                # don't send email when do_auth_check=False (e.g. admin panel move)
+                email_body = g.jinja2_env.get_template('allura:templates/mail/email_added.md').render(dict(
+                    user=user,
+                    config=config,
+                    addr=addr.email
+                ))
+                send_system_mail_to_user(user, 'New Email Address Added', email_body)
+
             addr.confirmed = True
             flash('Email address confirmed')
             h.auditlog_user('Email address verified: %s',  addr.email, user=user)
@@ -311,12 +320,7 @@ class AuthController(BaseController):
                 projectname = plugin.AuthenticationProvider.get(request).user_project_shortname(user)
                 n = M.Neighborhood.query.get(name='Users')
                 n.register_project(projectname, user=user, user_project=True)
-            email_body = g.jinja2_env.get_template('allura:templates/mail/email_added.md').render(dict(
-                user=user,
-                config=config,
-                addr=addr.email
-            ))
-            send_system_mail_to_user(user, 'New Email Address Added', email_body)
+
         else:
             flash('Unknown verification link', 'error')
 
@@ -584,12 +588,13 @@ class PreferencesController(BaseController):
                         primary_addr = None
                         user.set_tool_data('AuthPasswordReset', hash='', hash_expiry='')
                 h.auditlog_user('Email address deleted: %s', user.email_addresses[i], user=user)
-                email_body = g.jinja2_env.get_template('allura:templates/mail/email_removed.md').render(dict(
-                    user=user,
-                    config=config,
-                    addr=user.email_addresses[i]
-                ))
-                send_system_mail_to_user(user, 'Email Address Removed', email_body)
+                if not admin:
+                    email_body = g.jinja2_env.get_template('allura:templates/mail/email_removed.md').render(dict(
+                        user=user,
+                        config=config,
+                        addr=user.email_addresses[i]
+                    ))
+                    send_system_mail_to_user(user, 'Email Address Removed', email_body)
                 del user.email_addresses[i]
                 if obj:
                     obj.delete()
@@ -644,13 +649,14 @@ class PreferencesController(BaseController):
                     user.get_pref('email_address'),
                     primary_addr,
                     user=user)
-                email_body = g.jinja2_env.get_template('allura:templates/mail/primary_email_changed.md').render(dict(
-                    user=user,
-                    config=config,
-                    addr=primary_addr
-                ))
-                # send to previous primary addr
-                send_system_mail_to_user(old_primary_addr, 'Primary Email Address Changed', email_body)
+                if not admin:
+                    email_body = g.jinja2_env.get_template('allura:templates/mail/primary_email_changed.md').render(dict(
+                        user=user,
+                        config=config,
+                        addr=primary_addr
+                    ))
+                    # send to previous primary addr
+                    send_system_mail_to_user(old_primary_addr, 'Primary Email Address Changed', email_body)
             user.set_pref('email_address', primary_addr)
             user.set_tool_data('AuthPasswordReset', hash='', hash_expiry='')