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 2014/09/29 17:31:56 UTC
[1/4] git commit: [#7683] Optional primary email address reset
Repository: allura
Updated Branches:
refs/heads/master da0578956 -> dfcee1942
[#7683] Optional primary email address reset
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/d7f5a7c2
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/d7f5a7c2
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/d7f5a7c2
Branch: refs/heads/master
Commit: d7f5a7c2055d214ace74d16f139afed2292d3664
Parents: da05789
Author: Alexander Luberg <al...@slashdotmedia.com>
Authored: Wed Sep 24 11:31:31 2014 -0700
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Sep 29 15:31:40 2014 +0000
----------------------------------------------------------------------
Allura/allura/controllers/auth.py | 16 +++++++++---
Allura/allura/lib/plugin.py | 4 +++
Allura/allura/tests/functional/test_auth.py | 31 ++++++++++++++++++++++++
Allura/development.ini | 1 +
4 files changed, 48 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/d7f5a7c2/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 1f8c8aa..47fd90f 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -179,10 +179,19 @@ class AuthController(BaseController):
if not email:
redirect('/')
- email_record = M.EmailAddress.query.get(email=email, confirmed=True)
user_record = M.User.by_email_address(email)
+ allow_non_primary_email_reset = asbool(config.get('auth.allow_non_primary_email_password_reset', True))
- if user_record and email_record.confirmed:
+ if not allow_non_primary_email_reset:
+ message = 'A password reset email has been sent, if the given email address is on record as a primary email address.'
+ email_record = M.EmailAddress.query.get(email=provider.get_primary_email_address(user_record=user_record),
+ confirmed=True)
+ else:
+ message = 'A password reset email has been sent, if the given email address is on record in our system.'
+ email_record = M.EmailAddress.query.get(email=email, confirmed=True)
+
+
+ if user_record and email_record and email_record.confirmed:
hash = h.nonce(42)
user_record.set_tool_data('AuthPasswordReset',
hash=hash,
@@ -204,9 +213,8 @@ class AuthController(BaseController):
subject=subject,
message_id=h.gen_message_id(),
text=text)
-
h.auditlog_user('Password recovery link sent to: %s', email, user=user_record)
- flash('A password reset email has been sent, if the given email address is on record in our system.')
+ flash(message)
redirect('/')
@expose()
http://git-wip-us.apache.org/repos/asf/allura/blob/d7f5a7c2/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 78aae92..504a5f6 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -273,6 +273,10 @@ class AuthenticationProvider(object):
'''
raise NotImplementedError, 'get_last_password_updated'
+ def get_primary_email_address(self, user_record):
+ return user_record.get_pref('email_address')
+
+
def is_password_expired(self, user):
days = asint(config.get('auth.pwdexpire.days', 0))
before = asint(config.get('auth.pwdexpire.before', 0))
http://git-wip-us.apache.org/repos/asf/allura/blob/d7f5a7c2/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 39f5794..665f4ae 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -865,6 +865,37 @@ class TestPasswordReset(TestController):
@patch('allura.tasks.mail_tasks.sendsimplemail')
@patch('allura.lib.helpers.gen_message_id')
+ def test_only_primary_email_reset_allowed(self, gen_message_id, sendmail):
+ user = M.User.query.get(username='test-admin')
+ user.claim_address('aaa@aaa.com')
+ user.set_pref('email_address', 'aaa@aaa.com')
+ email = M.EmailAddress.query.find({'email': 'aaa@aaa.com'}).first()
+ email.confirmed = True
+ ThreadLocalORMSession.flush_all()
+ with h.push_config(config, **{'auth.allow_non_primary_email_password_reset': 'false'}):
+ self.app.post('/auth/password_recovery_hash', {'email': email.email})
+ hash = user.get_tool_data('AuthPasswordReset', 'hash')
+ assert hash is not None
+
+
+ @patch('allura.tasks.mail_tasks.sendsimplemail')
+ @patch('allura.lib.helpers.gen_message_id')
+ def test_non_primary_email_reset_allowed(self, gen_message_id, sendmail):
+ user = M.User.query.get(username='test-admin')
+ email1 = M.EmailAddress.query.find({'claimed_by_user_id': user._id}).first()
+ user.claim_address('aaa@aaa.com')
+ user.set_pref('email_address', 'aaa@aaa.com')
+ email = M.EmailAddress.query.find({'email': 'aaa@aaa.com'}).first()
+ email.confirmed = True
+ ThreadLocalORMSession.flush_all()
+ with h.push_config(config, **{'auth.allow_non_primary_email_password_reset': 'true'}):
+ self.app.post('/auth/password_recovery_hash', {'email': email1.email})
+ hash = user.get_tool_data('AuthPasswordReset', 'hash')
+ assert hash is not None
+
+
+ @patch('allura.tasks.mail_tasks.sendsimplemail')
+ @patch('allura.lib.helpers.gen_message_id')
def test_password_reset(self, gen_message_id, sendmail):
user = M.User.query.get(username='test-admin')
email = M.EmailAddress.query.find(
http://git-wip-us.apache.org/repos/asf/allura/blob/d7f5a7c2/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index 6142877..1ecaefc 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -109,6 +109,7 @@ auth.allow_password_change = true
auth.allow_upload_ssh_key = false
auth.allow_user_messages_config = true
auth.allow_birth_date = true
+auth.allow_non_primary_email_password_reset = true
auth.require_email_addr = true
# In seconds
[4/4] git commit: [#5700] Refactored & improved tests
Posted by br...@apache.org.
[#5700] Refactored & improved tests
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/b020149b
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/b020149b
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/b020149b
Branch: refs/heads/master
Commit: b020149b6954c22574f51562c73b1efd3d9b2620
Parents: 6a489c0
Author: Alexander Luberg <al...@slashdotmedia.com>
Authored: Fri Sep 26 12:06:16 2014 -0700
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Sep 29 15:31:41 2014 +0000
----------------------------------------------------------------------
Allura/allura/lib/plugin.py | 2 +-
Allura/allura/tests/functional/test_auth.py | 23 +++++++++++++++--------
2 files changed, 16 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/b020149b/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 504a5f6..bf4696f 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -274,7 +274,7 @@ class AuthenticationProvider(object):
raise NotImplementedError, 'get_last_password_updated'
def get_primary_email_address(self, user_record):
- return user_record.get_pref('email_address')
+ return user_record.get_pref('email_address') if user_record else None
def is_password_expired(self, user):
http://git-wip-us.apache.org/repos/asf/allura/blob/b020149b/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 665f4ae..4514725 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -839,6 +839,8 @@ class TestPreferences(TestController):
class TestPasswordReset(TestController):
+ test_primary_email = 'testprimaryaddr@mail.com'
+
@patch('allura.tasks.mail_tasks.sendmail')
@patch('allura.lib.helpers.gen_message_id')
def test_email_unconfirmed(self, gen_message_id, sendmail):
@@ -867,31 +869,36 @@ class TestPasswordReset(TestController):
@patch('allura.lib.helpers.gen_message_id')
def test_only_primary_email_reset_allowed(self, gen_message_id, sendmail):
user = M.User.query.get(username='test-admin')
- user.claim_address('aaa@aaa.com')
- user.set_pref('email_address', 'aaa@aaa.com')
- email = M.EmailAddress.query.find({'email': 'aaa@aaa.com'}).first()
+ user.claim_address(self.test_primary_email)
+ user.set_pref('email_address', self.test_primary_email)
+
+ email = M.EmailAddress.query.find({'email': self.test_primary_email}).first()
email.confirmed = True
ThreadLocalORMSession.flush_all()
+
with h.push_config(config, **{'auth.allow_non_primary_email_password_reset': 'false'}):
- self.app.post('/auth/password_recovery_hash', {'email': email.email})
+ self.app.post('/auth/password_recovery_hash', {'email': self.test_primary_email})
hash = user.get_tool_data('AuthPasswordReset', 'hash')
assert hash is not None
-
+ args, kwargs = sendmail.post.call_args
+ assert_equal(kwargs['toaddr'], self.test_primary_email)
@patch('allura.tasks.mail_tasks.sendsimplemail')
@patch('allura.lib.helpers.gen_message_id')
def test_non_primary_email_reset_allowed(self, gen_message_id, sendmail):
user = M.User.query.get(username='test-admin')
email1 = M.EmailAddress.query.find({'claimed_by_user_id': user._id}).first()
- user.claim_address('aaa@aaa.com')
- user.set_pref('email_address', 'aaa@aaa.com')
- email = M.EmailAddress.query.find({'email': 'aaa@aaa.com'}).first()
+ user.claim_address(self.test_primary_email)
+ user.set_pref('email_address', self.test_primary_email)
+ email = M.EmailAddress.query.find({'email': self.test_primary_email}).first()
email.confirmed = True
ThreadLocalORMSession.flush_all()
with h.push_config(config, **{'auth.allow_non_primary_email_password_reset': 'true'}):
self.app.post('/auth/password_recovery_hash', {'email': email1.email})
hash = user.get_tool_data('AuthPasswordReset', 'hash')
assert hash is not None
+ args, kwargs = sendmail.post.call_args
+ assert_equal(kwargs['toaddr'], email1.email)
@patch('allura.tasks.mail_tasks.sendsimplemail')
[2/4] git commit: [#7683] Bugfix
Posted by br...@apache.org.
[#7683] Bugfix
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/6a489c09
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/6a489c09
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/6a489c09
Branch: refs/heads/master
Commit: 6a489c0915e6fa9a4fbfe92a01f84ee0a1f39323
Parents: d7f5a7c
Author: Alexander Luberg <al...@slashdotmedia.com>
Authored: Wed Sep 24 12:25:35 2014 -0700
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Sep 29 15:31:41 2014 +0000
----------------------------------------------------------------------
Allura/allura/controllers/auth.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/6a489c09/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 47fd90f..8944f74 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -198,7 +198,7 @@ class AuthController(BaseController):
hash_expiry=datetime.datetime.utcnow() +
datetime.timedelta(seconds=int(config.get('auth.recovery_hash_expiry_period', 600))))
- log.info('Sending password recovery link to %s', email)
+ log.info('Sending password recovery link to %s', email_record.email)
subject = '%s Password recovery' % config['site_name']
text = g.jinja2_env.get_template('allura:templates/mail/forgot_password.txt').render(dict(
user=user_record,
@@ -207,7 +207,7 @@ class AuthController(BaseController):
))
allura.tasks.mail_tasks.sendsimplemail.post(
- toaddr=email,
+ toaddr=email_record.email,
fromaddr=config['forgemail.return_path'],
reply_to=config['forgemail.return_path'],
subject=subject,
[3/4] git commit: [#5700] Updated notification message
Posted by br...@apache.org.
[#5700] Updated notification message
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/dfcee194
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/dfcee194
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/dfcee194
Branch: refs/heads/master
Commit: dfcee1942847661d94a0d1504163d3e82e029d24
Parents: b020149
Author: Alexander Luberg <al...@slashdotmedia.com>
Authored: Fri Sep 26 12:07:57 2014 -0700
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Sep 29 15:31:41 2014 +0000
----------------------------------------------------------------------
Allura/allura/controllers/auth.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/dfcee194/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 8944f74..ecd3d0c 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -183,7 +183,7 @@ class AuthController(BaseController):
allow_non_primary_email_reset = asbool(config.get('auth.allow_non_primary_email_password_reset', True))
if not allow_non_primary_email_reset:
- message = 'A password reset email has been sent, if the given email address is on record as a primary email address.'
+ message = 'If the given email address is on record, a password reset email has been sent to the account\'s primary email address.'
email_record = M.EmailAddress.query.get(email=provider.get_primary_email_address(user_record=user_record),
confirmed=True)
else: