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

Commit 2abfcf1

Browse files
committed
Fix mozillians.org logins from mozilla SSO.
1 parent 00db09b commit 2abfcf1

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

mozillians/common/authbackend.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def filter_users_by_claims(self, claims):
5858
user=request_user.userprofile,
5959
identifier=email)
6060
else:
61-
msg = u'Email {0} already exists in the database.'.format(email)
62-
messages.error(self.request, msg)
61+
if not user_q.filter(pk=request_user.id).exists():
62+
msg = u'Email {0} already exists in the database.'.format(email)
63+
messages.error(self.request, msg)
6364
return [request_user]
6465
return user_q

mozillians/common/tests/test_authbackend.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ def test_alternate_email_already_exists(self, mocked_message):
7070
ok_(email_q.exists())
7171
eq_(len(returned_user), 1)
7272
eq_(returned_user[0], user)
73-
mocked_message.assert_called_once_with(request_mock, u'Email bar@example.com already '
74-
'exists in the database.')
73+
ok_(not mocked_message.called)
7574

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

9795
@patch('mozillians.common.authbackend.messages.error')

0 commit comments

Comments
 (0)