aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/authtoken/serializers.py
diff options
context:
space:
mode:
Diffstat (limited to 'rest_framework/authtoken/serializers.py')
-rw-r--r--rest_framework/authtoken/serializers.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/rest_framework/authtoken/serializers.py b/rest_framework/authtoken/serializers.py
index 60a3740e..37ade255 100644
--- a/rest_framework/authtoken/serializers.py
+++ b/rest_framework/authtoken/serializers.py
@@ -1,5 +1,7 @@
from django.contrib.auth import authenticate
-from rest_framework import serializers
+from django.utils.translation import ugettext_lazy as _
+
+from rest_framework import exceptions, serializers
class AuthTokenSerializer(serializers.Serializer):
@@ -15,10 +17,14 @@ class AuthTokenSerializer(serializers.Serializer):
if user:
if not user.is_active:
- raise serializers.ValidationError('User account is disabled.')
- attrs['user'] = user
- return attrs
+ msg = _('User account is disabled.')
+ raise exceptions.ValidationError(msg)
else:
- raise serializers.ValidationError('Unable to login with provided credentials.')
+ msg = _('Unable to log in with provided credentials.')
+ raise exceptions.ValidationError(msg)
else:
- raise serializers.ValidationError('Must include "username" and "password"')
+ msg = _('Must include "username" and "password".')
+ raise exceptions.ValidationError(msg)
+
+ attrs['user'] = user
+ return attrs