Fix Logout Anonymous User

Insert a proper response when the user is anonymous on the logout view

Fixes https://github.com/Tivix/django-rest-auth/issues/332
This commit is contained in:
NikosVlagoidis 2017-06-29 16:03:56 +03:00
parent 9d1f65eedc
commit 9dfb2dc49e

View File

@ -119,7 +119,8 @@ class LogoutView(APIView):
try:
request.user.auth_token.delete()
except (AttributeError, ObjectDoesNotExist):
pass
return Response({"detail": _("Cannot log out Anonymous User")},
status=status.HTTP_400_BAD_REQUEST)
django_logout(request)