]> git.parisson.com Git - django-social-auth.git/commitdiff
Replace raw ORM query for User by email with new models module method
authorSteven Cummings <estebistec@gmail.com>
Mon, 25 Jun 2012 04:07:46 +0000 (23:07 -0500)
committerSteven Cummings <estebistec@gmail.com>
Mon, 25 Jun 2012 04:07:46 +0000 (23:07 -0500)
social_auth/backends/pipeline/associate.py
social_auth/django_models.py
social_auth/mongoengine_models.py

index fd7c850756b65735ef934cf90884eb9071c0d755..225844b1d6f5d1794731c4bd3e787069a074f815 100644 (file)
@@ -1,5 +1,5 @@
 from social_auth.utils import setting
-from social_auth.models import User
+from social_auth.models import get_user_by_email
 from social_auth.backends.pipeline import warn_setting
 from social_auth.backends.exceptions import AuthException
 
@@ -15,7 +15,7 @@ def associate_by_email(details, *args, **kwargs):
         # only if it's a single object. AuthException is raised if multiple
         # objects are returned
         try:
-            return {'user': User.objects.get(email=email)}
+            return {'user': get_user_by_email(email=email)}
         except User.MultipleObjectsReturned:
             raise AuthException(kwargs['backend'], 'Not unique email address.')
         except User.DoesNotExist:
index ed37b0d73165a2e2d3c704cf4a4fb8e285862054..c10ded84bf59c3de4126ff6652ff9e0aabbb43d9 100644 (file)
@@ -47,6 +47,10 @@ def get_user(user_id):
         return None
 
 
+def get_user_by_email(email):
+    return User.objects.get(email=email)
+
+
 def get_social_auth_for_user(user):
     return user.social_auth.all()
 
index 6a2a27d3f2fe1e6108d6a4cf430248a0d6dce9c8..7de80102bb74aaf072a89e1fa158e53ca9086b81 100644 (file)
@@ -55,6 +55,10 @@ def get_user(user_id):
         return None
 
 
+def get_user_by_email(email):
+    return User.objects.get(email=email)
+
+
 def get_social_auth_for_user(user):
     return UserSocialAuth.objects(user=user)