aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/authtoken/serializers.py
diff options
context:
space:
mode:
authorXavier Ordoquy2014-11-26 16:36:56 +0100
committerXavier Ordoquy2014-11-26 16:36:56 +0100
commitf5e5ed0077cc477a7b8af98c7b10d8d3701f1a65 (patch)
tree252729a9e61deb0dbc1a098feb1c55eae56ca948 /rest_framework/authtoken/serializers.py
parent311d315a739f4d1d02e87a09de0bbf9e7b0cee46 (diff)
parent2647e1aaaadfc2cfd947c633399dca1060c17401 (diff)
downloaddjango-rest-framework-f5e5ed0077cc477a7b8af98c7b10d8d3701f1a65.tar.bz2
Merge remote-tracking branch 'reference/master' into bugfix/1850
Diffstat (limited to 'rest_framework/authtoken/serializers.py')
-rw-r--r--rest_framework/authtoken/serializers.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/rest_framework/authtoken/serializers.py b/rest_framework/authtoken/serializers.py
index 472e59ee..f31dded1 100644
--- a/rest_framework/authtoken/serializers.py
+++ b/rest_framework/authtoken/serializers.py
@@ -1,7 +1,7 @@
from django.contrib.auth import authenticate
from django.utils.translation import ugettext_lazy as _
-from rest_framework import serializers
+from rest_framework import exceptions, serializers
class AuthTokenSerializer(serializers.Serializer):
@@ -18,12 +18,13 @@ class AuthTokenSerializer(serializers.Serializer):
if user:
if not user.is_active:
msg = _('User account is disabled.')
- raise serializers.ValidationError(msg)
- attrs['user'] = user
- return attrs
+ raise exceptions.ValidationError(msg)
else:
msg = _('Unable to log in with provided credentials.')
- raise serializers.ValidationError(msg)
+ raise exceptions.ValidationError(msg)
else:
msg = _('Must include "username" and "password"')
- raise serializers.ValidationError(msg)
+ raise exceptions.ValidationError(msg)
+
+ attrs['user'] = user
+ return attrs