allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kentontay...@apache.org
Subject allura git commit: [#8156] notify upon password change
Date Wed, 12 Jul 2017 17:18:35 GMT
Repository: allura
Updated Branches:
  refs/heads/master 5ef5bca59 -> bdcdcbf5a


[#8156] notify upon password change


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/bdcdcbf5
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/bdcdcbf5
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/bdcdcbf5

Branch: refs/heads/master
Commit: bdcdcbf5a6aa52d45c7639d5ee001c99a5f07da2
Parents: 5ef5bca
Author: Dave Brondsema <dave@brondsema.net>
Authored: Thu Jun 29 11:26:31 2017 -0400
Committer: Kenton Taylor <ktaylor@slashdotmedia.com>
Committed: Wed Jul 12 16:20:43 2017 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py               |  5 ++++
 .../allura/templates/mail/password_changed.md   | 26 ++++++++++++++++++++
 Allura/allura/tests/functional/test_auth.py     | 23 +++++++++++------
 3 files changed, 46 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/bdcdcbf5/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index e3ed706..47246ae 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -653,6 +653,11 @@ class PreferencesController(BaseController):
             redirect('.')
         flash('Password changed')
         h.auditlog_user('Password changed')
+        email_body = g.jinja2_env.get_template('allura:templates/mail/password_changed.md').render(dict(
+            user=c.user,
+            config=config,
+        ))
+        send_system_mail_to_user(c.user, u'Password Changed', email_body)
         redirect('.')
 
     @expose()

http://git-wip-us.apache.org/repos/asf/allura/blob/bdcdcbf5/Allura/allura/templates/mail/password_changed.md
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/mail/password_changed.md b/Allura/allura/templates/mail/password_changed.md
new file mode 100644
index 0000000..10e062f
--- /dev/null
+++ b/Allura/allura/templates/mail/password_changed.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 }},
+
+The password for your {{ config['site_name'] }} account "{{ user.username }}" has been changed.
 This is a confirmation email, you are all set.
+
+{% block footer %}
+If you did not do this, please contact us immediately.
+{% endblock %}

http://git-wip-us.apache.org/repos/asf/allura/blob/bdcdcbf5/Allura/allura/tests/functional/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index bd8dc9c..1e0a086 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -466,14 +466,15 @@ class TestAuth(TestController):
         old_pass = user.get_pref('password')
 
         # Change password
-        self.app.post('/auth/preferences/change_password',
-                      extra_environ=dict(username='test-admin'),
-                      params={
-                          'oldpw': 'foo',
-                          'pw': 'asdfasdf',
-                          'pw2': 'asdfasdf',
-                          '_session_id': self.app.cookies['_session_id'],
-                      })
+        with audits('Password changed', user=True):
+            self.app.post('/auth/preferences/change_password',
+                          extra_environ=dict(username='test-admin'),
+                          params={
+                              'oldpw': 'foo',
+                              'pw': 'asdfasdf',
+                              'pw2': 'asdfasdf',
+                              '_session_id': self.app.cookies['_session_id'],
+                          })
 
         # Confirm password was changed.
         assert_not_equal(old_pass, user.get_pref('password'))
@@ -482,6 +483,12 @@ class TestAuth(TestController):
         assert_equal(user.get_tool_data('AuthPasswordReset', 'hash'), '')
         assert_equal(user.get_tool_data('AuthPasswordReset', 'hash_expiry'), '')
 
+        # Confirm an email was sent
+        tasks = M.MonQTask.query.find(dict(task_name='allura.tasks.mail_tasks.sendsimplemail')).all()
+        assert_equal(len(tasks), 1)
+        assert_equal(tasks[0].kwargs['subject'], 'Password Changed')
+        assert_in('The password for your', tasks[0].kwargs['text'])
+
     @td.with_user_project('test-admin')
     def test_prefs(self):
         r = self.app.get('/auth/preferences/',


Mime
View raw message