Commit fdb6c13e authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg

Merge branch '959-auth-status-code' into 'master'

Fix API authentication returns 400 when providing the wrong credentials

Closes #959

See merge request !1412
parents d1b61272 e58805a9
......@@ -42,7 +42,10 @@ class ObtainThaliaAuthToken(ObtainAuthToken):
if 'username' in request.data else None,
'password': request.data.get('password')
}, context={'request': request})
serializer.is_valid(raise_exception=True)
if not serializer.is_valid():
return HttpResponse('Unauthorized', status=401)
user = serializer.validated_data['user']
token, created = Token.objects.get_or_create(user=user)
return Response({'token': token.key})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment