Commit e58805a9 authored by Simcha van Collem's avatar Simcha van Collem

Wrong credentials now returns 401

parent 217ebb8d
......@@ -40,7 +40,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