]> git.parisson.com Git - django-social-auth.git/commitdiff
Fix error on context processor. Closes gh-137.
authorMatías Aguirre <matiasaguirre@gmail.com>
Mon, 29 Aug 2011 19:11:39 +0000 (16:11 -0300)
committerMatías Aguirre <matiasaguirre@gmail.com>
Mon, 29 Aug 2011 19:11:39 +0000 (16:11 -0300)
social_auth/context_processors.py

index e90583947246cbdfdd35173bfa172e420681c3d0..96f7c19bfbd4b2b1242dc95a31b55bc0a8862704 100644 (file)
@@ -1,5 +1,6 @@
 from social_auth.backends import BACKENDS
 from social_auth.utils import group_backend_by_type
+from social_auth.models import User
 
 
 # Note: social_auth_backends and social_auth_by_type_backends don't play nice
@@ -42,7 +43,9 @@ def backends_data(user):
               'not_associated': available,
               'backends': available}
 
-    if user.is_authenticated():
+    # user comes from request.user usually, on /admin/ it will be an instance
+    # of auth.User and this code will fail if a custom User model was defined
+    if isinstance(user, User) and user.is_authenticated():
         associated = user.social_auth.all()
         not_associated = list(set(available) -
                               set(assoc.provider for assoc in associated))