Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1698 from johngian/fix-multiple-emails
Browse files Browse the repository at this point in the history
Fix mozillians.org logins from mozilla SSO.
  • Loading branch information
johngian committed May 2, 2017
2 parents 00db09b + 2abfcf1 commit 46899f2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 3 additions & 2 deletions mozillians/common/authbackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def filter_users_by_claims(self, claims):
user=request_user.userprofile,
identifier=email)
else:
msg = u'Email {0} already exists in the database.'.format(email)
messages.error(self.request, msg)
if not user_q.filter(pk=request_user.id).exists():
msg = u'Email {0} already exists in the database.'.format(email)
messages.error(self.request, msg)
return [request_user]
return user_q
6 changes: 2 additions & 4 deletions mozillians/common/tests/test_authbackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ def test_alternate_email_already_exists(self, mocked_message):
ok_(email_q.exists())
eq_(len(returned_user), 1)
eq_(returned_user[0], user)
mocked_message.assert_called_once_with(request_mock, u'Email bar@example.com already '
'exists in the database.')
ok_(not mocked_message.called)

@patch('mozillians.common.authbackend.messages.error')
def test_add_primary_email_as_alternate(self, mocked_message):
Expand All @@ -90,8 +89,7 @@ def test_add_primary_email_as_alternate(self, mocked_message):
email_q = ExternalAccount.objects.filter(type=ExternalAccount.TYPE_EMAIL,
user=user.userprofile,
identifier='foo@example.com')
mocked_message.assert_called_once_with(request_mock, u'Email foo@example.com already '
'exists in the database.')
ok_(not mocked_message.called)
ok_(not email_q.exists())

@patch('mozillians.common.authbackend.messages.error')
Expand Down

0 comments on commit 46899f2

Please sign in to comment.