aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/request.py
diff options
context:
space:
mode:
authorTom Christie2013-02-10 20:08:36 +0000
committerTom Christie2013-02-10 20:08:36 +0000
commit870f10486cd347480fb16d95647d1ca4a72d83d4 (patch)
tree001aab1d8975df589cee29cb4a7e06b616793fec /rest_framework/request.py
parent29136ef2c6338b8dbc9f7cf9c4dd75867a6bfa9f (diff)
downloaddjango-rest-framework-870f10486cd347480fb16d95647d1ca4a72d83d4.tar.bz2
Fix incorrect 401 vs 403 response, if lazy authentication has not taken place.
Diffstat (limited to 'rest_framework/request.py')
-rw-r--r--rest_framework/request.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/rest_framework/request.py b/rest_framework/request.py
index 482c8688..47c009b2 100644
--- a/rest_framework/request.py
+++ b/rest_framework/request.py
@@ -88,7 +88,6 @@ class Request(object):
self._method = Empty
self._content_type = Empty
self._stream = Empty
- self._authenticator = None
if self.parser_context is None:
self.parser_context = {}
@@ -175,12 +174,12 @@ class Request(object):
@user.setter
def user(self, value):
- """
- Sets the user on the current request. This is necessary to maintain
- compatilbility with django.contrib.auth where the user proprety is
- set in the login and logout functions.
- """
- self._user = value
+ """
+ Sets the user on the current request. This is necessary to maintain
+ compatilbility with django.contrib.auth where the user proprety is
+ set in the login and logout functions.
+ """
+ self._user = value
@property
def auth(self):
@@ -206,6 +205,8 @@ class Request(object):
Return the instance of the authentication instance class that was used
to authenticate the request, or `None`.
"""
+ if not hasattr(self, '_authenticator'):
+ self._authenticator, self._user, self._auth = self._authenticate()
return self._authenticator
def _load_data_and_files(self):