From 8b4ce5c636a9abb33029e48f969bbdf38f97ca1f Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 4 Feb 2015 09:07:10 +0000 Subject: [PATCH] Minor authentication message improvement. --- env/pip-selfcheck.json | 1 + rest_framework/authentication.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 env/pip-selfcheck.json diff --git a/env/pip-selfcheck.json b/env/pip-selfcheck.json new file mode 100644 index 000000000..ad56313b1 --- /dev/null +++ b/env/pip-selfcheck.json @@ -0,0 +1 @@ +{"last_check":"2015-02-04T09:06:02Z","pypi_version":"6.0.7"} \ No newline at end of file diff --git a/rest_framework/authentication.py b/rest_framework/authentication.py index 11db05855..a75cd30cd 100644 --- a/rest_framework/authentication.py +++ b/rest_framework/authentication.py @@ -86,8 +86,13 @@ class BasicAuthentication(BaseAuthentication): Authenticate the userid and password against username and password. """ user = authenticate(username=userid, password=password) - if user is None or not user.is_active: + + if user is None: raise exceptions.AuthenticationFailed(_('Invalid username/password.')) + + if not user.is_active: + raise exceptions.AuthenticationFailed(_('User inactive or deleted.')) + return (user, None) def authenticate_header(self, request):