mirror of
https://github.com/Tivix/django-rest-auth.git
synced 2025-02-06 13:10:32 +03:00
pep8 cleanups
This commit is contained in:
parent
945008d326
commit
f89471f980
|
@ -116,18 +116,19 @@ class SocialLoginSerializer(serializers.Serializer):
|
|||
# with the same email address: raise an exception.
|
||||
# This needs to be handled in the frontend. We can not just
|
||||
# link up the accounts due to security constraints
|
||||
if(allauth_settings.UNIQUE_EMAIL):
|
||||
if allauth_settings.UNIQUE_EMAIL:
|
||||
# Do we have an account already with this email address?
|
||||
existing_account = get_user_model().objects.filter(
|
||||
account_exists = get_user_model().objects.filter(
|
||||
email=login.user.email,
|
||||
).count()
|
||||
if(existing_account != 0):
|
||||
# There is an account already
|
||||
).exists()
|
||||
if account_exists:
|
||||
raise serializers.ValidationError(
|
||||
_("A user is already registered with this e-mail address."))
|
||||
_("User is already registered with this e-mail address.")
|
||||
)
|
||||
|
||||
login.lookup()
|
||||
login.save(request, connect=True)
|
||||
|
||||
attrs['user'] = login.account.user
|
||||
|
||||
return attrs
|
||||
|
|
|
@ -225,7 +225,7 @@ class TestSocialAuth(TestsMixin, TestCase):
|
|||
REST_SESSION_LOGIN=False,
|
||||
ACCOUNT_EMAIL_CONFIRMATION_HMAC=False
|
||||
)
|
||||
def test_edge_case(self):
|
||||
def test_email_clash_with_existing_account(self):
|
||||
resp_body = {
|
||||
"id": "123123123123",
|
||||
"first_name": "John",
|
||||
|
@ -251,6 +251,8 @@ class TestSocialAuth(TestsMixin, TestCase):
|
|||
|
||||
# test empty payload
|
||||
self.post(self.register_url, data={}, status_code=400)
|
||||
|
||||
# register user and send email confirmation
|
||||
self.post(
|
||||
self.register_url,
|
||||
data=self.REGISTRATION_DATA,
|
||||
|
@ -271,16 +273,11 @@ class TestSocialAuth(TestsMixin, TestCase):
|
|||
self._login()
|
||||
self._logout()
|
||||
|
||||
# fb log in with already existing email
|
||||
payload = {
|
||||
'access_token': 'abc123'
|
||||
}
|
||||
|
||||
# You should not have access to an account created through register
|
||||
# by loging in through FB with an account that has the same
|
||||
# email address.
|
||||
self.post(self.fb_login_url, data=payload, status_code=400)
|
||||
# self.post(self.fb_login_url, data=payload, status_code=200)
|
||||
# self.assertIn('key', self.response.json.keys())
|
||||
|
||||
@responses.activate
|
||||
@override_settings(
|
||||
|
|
Loading…
Reference in New Issue
Block a user