aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/authtoken/serializers.py
diff options
context:
space:
mode:
authorCarlton Gibson2014-11-18 16:42:39 +0100
committerCarlton Gibson2014-11-18 16:42:39 +0100
commitc50a42bddc66e28d624cd3caadd2d63502ac2e6e (patch)
treebf03e2dcb23c2e4f372ff00cba4a810a96c24681 /rest_framework/authtoken/serializers.py
parentba52c0c62762b9976fffa72dde7ce922176e481d (diff)
parent080bd3d24e1866df2acc3aae0ec0f97ebe3a8c36 (diff)
downloaddjango-rest-framework-c50a42bddc66e28d624cd3caadd2d63502ac2e6e.tar.bz2
Merge branch 'master' of github.com:tomchristie/django-rest-framework
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