Do no try to retrieve an OAuth2 token when there is no user
Closes #5900
This commit is contained in:
parent
01259aa963
commit
defce175d0
|
@ -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:
|
||||
|
|
Reference in New Issue