diff options
| author | James Rutherford | 2015-03-11 10:38:03 +0000 | 
|---|---|---|
| committer | James Rutherford | 2015-03-11 10:38:03 +0000 | 
| commit | 4a2d27975ab5249269aebafd803be87a2107092b (patch) | |
| tree | 55b524c93b02eef404304f734be98871bbb1324f /rest_framework/authtoken/serializers.py | |
| parent | 856dc855c952746f566a6a8de263afe951362dfb (diff) | |
| parent | dc56e5a0f41fdd6350e91a5749023d086bd1640f (diff) | |
| download | django-rest-framework-4a2d27975ab5249269aebafd803be87a2107092b.tar.bz2 | |
Merge pull request #1 from tomchristie/master
Merge in from upstream
Diffstat (limited to 'rest_framework/authtoken/serializers.py')
| -rw-r--r-- | rest_framework/authtoken/serializers.py | 18 | 
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 | 
