Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions ietf/ietfauth/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,21 @@ def test_reset_password_address_handling(self):
self.assertIn(active_address, to)
self.assertNotIn(person.user.username, to)

def test_reset_password_without_username(self):
"""Reset password using non-username email address"""
url = urlreverse('ietf.ietfauth.views.password_reset')
person = PersonFactory()
secondary_address = EmailFactory(person=person).address
inactive_secondary_address = EmailFactory(person=person, active=False).address
empty_outbox()
r = self.client.post(url, { 'username': secondary_address})
self.assertContains(r, 'We have sent you an email with instructions', status_code=200)
self.assertEqual(len(outbox), 1)
to = outbox[0].get('To')
self.assertIn(person.user.username, to)
self.assertIn(secondary_address, to)
self.assertNotIn(inactive_secondary_address, to)

def test_review_overview(self):
review_req = ReviewRequestFactory()
assignment = ReviewAssignmentFactory(review_request=review_req,reviewer=EmailFactory(person__user__username='reviewer'))
Expand Down
6 changes: 6 additions & 0 deletions ietf/ietfauth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,12 @@ def password_reset(request):
# We still report that the action succeeded, so we're not leaking the existence of user
# email addresses.
user = User.objects.filter(username__iexact=submitted_username, person__isnull=False).first()
if not user:
# try to find user ID from the email address
email = Email.objects.filter(address=submitted_username).first()
if email and email.person and email.person.user:
user = email.person.user

if user and user.person.email_set.filter(active=True).exists():
data = {
'username': user.username,
Expand Down