From c66baf9a2cef370cd28be812b705c2c4597435cc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mat=C3=ADas=20Aguirre?= Date: Thu, 14 Apr 2011 10:07:58 -0300 Subject: [PATCH] Fix email association if clause. Closes gh-51. --- social_auth/backends/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/social_auth/backends/__init__.py b/social_auth/backends/__init__.py index 8e867c8..5325660 100644 --- a/social_auth/backends/__init__.py +++ b/social_auth/backends/__init__.py @@ -115,7 +115,10 @@ class SocialAuthBackend(ModelBackend): return None email = details.get('email') - if ASSOCIATE_BY_MAIL: + if email and ASSOCIATE_BY_MAIL: + # try to associate accounts registered with the same email + # address, only if it's a single object. ValueError is + # raised if multiple objects are returned try: user = User.objects.get(email=email) except MultipleObjectsReturned: -- 2.39.5