mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 11:33:59 +03:00
Better to return 401 when failing to authenticate
This commit is contained in:
parent
11ef60b127
commit
7eec582d40
|
@ -18,7 +18,7 @@ class ObtainAuthToken(APIView):
|
|||
if serializer.is_valid():
|
||||
token, created = Token.objects.get_or_create(user=serializer.object['user'])
|
||||
return Response({'token': token.key})
|
||||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
||||
return Response(serializer.errors, status=status.HTTP_401_UNAUTHORIZED)
|
||||
|
||||
|
||||
obtain_auth_token = ObtainAuthToken.as_view()
|
||||
|
|
Loading…
Reference in New Issue
Block a user