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 2017/06/29 17:23:36 UTC
allura git commit: [#8156] notify upon password change
Repository: allura
Updated Branches:
refs/heads/db/8156 [created] 2f2e3f93d
[#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/2f2e3f93
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/2f2e3f93
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/2f2e3f93
Branch: refs/heads/db/8156
Commit: 2f2e3f93d8c411188ca57291cc185b68f8b3bb74
Parents: 48bdb32
Author: Dave Brondsema <da...@brondsema.net>
Authored: Thu Jun 29 11:26:31 2017 -0400
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Thu Jun 29 13:23:32 2017 -0400
----------------------------------------------------------------------
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/2f2e3f93/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 284f750..ffeead3 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -651,6 +651,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/2f2e3f93/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/2f2e3f93/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 b7b28be..caba72e 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -460,14 +460,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'))
@@ -476,6 +477,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/',