Fixed 500 error in authentication
This commit is contained in:
parent
3753193c10
commit
e4c044638b
|
@ -9,6 +9,7 @@ from rest_framework import exceptions
|
||||||
from rest_framework_jwt.settings import api_settings
|
from rest_framework_jwt.settings import api_settings
|
||||||
from rest_framework_jwt.authentication import BaseJSONWebTokenAuthentication
|
from rest_framework_jwt.authentication import BaseJSONWebTokenAuthentication
|
||||||
|
|
||||||
|
from funkwhale_api.users.models import User
|
||||||
|
|
||||||
|
|
||||||
class TokenHeaderAuth(BaseJSONWebTokenAuthentication):
|
class TokenHeaderAuth(BaseJSONWebTokenAuthentication):
|
||||||
|
@ -40,7 +41,7 @@ class TokenAuthMiddleware:
|
||||||
auth = TokenHeaderAuth()
|
auth = TokenHeaderAuth()
|
||||||
try:
|
try:
|
||||||
user, token = auth.authenticate(scope)
|
user, token = auth.authenticate(scope)
|
||||||
except exceptions.AuthenticationFailed:
|
except (User.DoesNotExist, exceptions.AuthenticationFailed):
|
||||||
user = AnonymousUser()
|
user = AnonymousUser()
|
||||||
|
|
||||||
scope['user'] = user
|
scope['user'] = user
|
||||||
|
|
Loading…
Reference in New Issue