Raise 401 error when login failed

Authtoken was raising a 400 error code when trying to log in with invalid username/password when it should raise a 401 error (Unauthorized)
This commit is contained in:
Matías Lang 2014-12-12 14:34:14 -03:00
parent fd473aa905
commit 24b49f8cc5

View File

@ -18,10 +18,10 @@ class AuthTokenSerializer(serializers.Serializer):
if user:
if not user.is_active:
msg = _('User account is disabled.')
raise exceptions.ValidationError(msg)
raise exceptions.AuthenticationFailed(msg)
else:
msg = _('Unable to log in with provided credentials.')
raise exceptions.ValidationError(msg)
raise exceptions.AuthenticationFailed(msg)
else:
msg = _('Must include "username" and "password"')
raise exceptions.ValidationError(msg)