]> git.parisson.com Git - django-social-auth.git/commitdiff
In context-processor, replace type-check with check for auth method
authorSteven Cummings <estebistec@gmail.com>
Mon, 25 Jun 2012 04:19:38 +0000 (23:19 -0500)
committerSteven Cummings <estebistec@gmail.com>
Mon, 25 Jun 2012 04:19:38 +0000 (23:19 -0500)
social_auth/context_processors.py

index e7d5531726dec2c47b3630bcdf3e427b9fecb97a..99c39d6699eb7c06a057723d4273efa23eeb7090 100644 (file)
@@ -1,6 +1,5 @@
 from social_auth.backends import get_backends
 from social_auth.utils import group_backend_by_type
-from social_auth.models import User
 from social_auth.models import get_social_auth_for_user
 
 
@@ -39,7 +38,7 @@ def social_auth_by_name_backends(request):
     accounts = dict(zip(keys, [None] * len(keys)))
     user = request.user
 
-    if isinstance(user, User) and user.is_authenticated():
+    if hasattr(user, 'is_authenticated') and user.is_authenticated():
         accounts.update((assoc.provider.replace('-', '_'), assoc)
                             for assoc in get_social_auth_for_user(user))
 
@@ -65,7 +64,7 @@ def backends_data(user):
 
     # 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():
+    if hasattr(user, 'is_authenticated') and user.is_authenticated():
         associated = get_social_auth_for_user(user)
         not_associated = list(set(available) -
                               set(assoc.provider for assoc in associated))