Do no try to retrieve an OAuth2 token when there is no user

Closes #5900
This commit is contained in:
Benjamin Dauvergne 2014-11-07 11:26:27 +01:00 committed by Serghei MIHAI
parent 01259aa963
commit defce175d0
1 changed files with 10 additions and 9 deletions

View File

@ -159,15 +159,16 @@ class Data(object):
from allauth.socialaccount.models import SocialToken
user = self.request.user
try:
token = SocialToken.objects.get(
account__provider='authentic2',
account__user=user)
log.debug('found access token: %r', token)
return token.token
except SocialToken.DoesNotExist:
log.warning('unable to find a social token for user: %r', user)
return ''
if user.is_authenticated():
try:
token = SocialToken.objects.get(
account__provider='authentic2',
account__user=user)
log.debug('found access token: %r', token)
return token.token
except SocialToken.DoesNotExist:
log.warning('unable to find a social token for user: %r', user)
return ''
def resolve_http_url(self):
try: