Fixed 500 error in authentication

merge-requests/154/head
Eliot Berriot 2018-03-05 21:43:07 +01:00
rodzic 3753193c10
commit e4c044638b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: DD6965E2476E5C27
1 zmienionych plików z 2 dodań i 1 usunięć

Wyświetl plik

@ -9,6 +9,7 @@ from rest_framework import exceptions
from rest_framework_jwt.settings import api_settings
from rest_framework_jwt.authentication import BaseJSONWebTokenAuthentication
from funkwhale_api.users.models import User
class TokenHeaderAuth(BaseJSONWebTokenAuthentication):
@ -40,7 +41,7 @@ class TokenAuthMiddleware:
auth = TokenHeaderAuth()
try:
user, token = auth.authenticate(scope)
except exceptions.AuthenticationFailed:
except (User.DoesNotExist, exceptions.AuthenticationFailed):
user = AnonymousUser()
scope['user'] = user