From e4c044638beafbff33bc8282b0e17cdf0215a5e9 Mon Sep 17 00:00:00 2001
From: Eliot Berriot <contact@eliotberriot.com>
Date: Mon, 5 Mar 2018 21:43:07 +0100
Subject: [PATCH] Fixed 500 error in authentication

---
 api/funkwhale_api/common/auth.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/api/funkwhale_api/common/auth.py b/api/funkwhale_api/common/auth.py
index 6f99b3bb..75839b93 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
-- 
GitLab