From: Steven Cummings Date: Mon, 25 Jun 2012 04:19:38 +0000 (-0500) Subject: In context-processor, replace type-check with check for auth method X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=cbe98f2706d87b31479341ffe80ee5b14007f104;p=django-social-auth.git In context-processor, replace type-check with check for auth method --- diff --git a/social_auth/context_processors.py b/social_auth/context_processors.py index e7d5531..99c39d6 100644 --- a/social_auth/context_processors.py +++ b/social_auth/context_processors.py @@ -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))