From cbe98f2706d87b31479341ffe80ee5b14007f104 Mon Sep 17 00:00:00 2001 From: Steven Cummings Date: Sun, 24 Jun 2012 23:19:38 -0500 Subject: [PATCH] In context-processor, replace type-check with check for auth method --- social_auth/context_processors.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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)) -- 2.39.5