diff --git a/api/funkwhale_api/common/auth.py b/api/funkwhale_api/common/auth.py index 6f99b3bba26b36fbce61dd03fb608cb2cb61f6ba..75839b93662bfb0eb19a78d3b108c5c3690e5e5d 100644 --- a/api/funkwhale_api/common/auth.py +++ b/api/funkwhale_api/common/auth.py @@ -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