mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 11:33:59 +03:00
Fix incorrect 401 vs 403 response, if lazy authentication has not taken place.
This commit is contained in:
parent
29136ef2c6
commit
870f10486c
|
@ -88,7 +88,6 @@ class Request(object):
|
||||||
self._method = Empty
|
self._method = Empty
|
||||||
self._content_type = Empty
|
self._content_type = Empty
|
||||||
self._stream = Empty
|
self._stream = Empty
|
||||||
self._authenticator = None
|
|
||||||
|
|
||||||
if self.parser_context is None:
|
if self.parser_context is None:
|
||||||
self.parser_context = {}
|
self.parser_context = {}
|
||||||
|
@ -175,12 +174,12 @@ class Request(object):
|
||||||
|
|
||||||
@user.setter
|
@user.setter
|
||||||
def user(self, value):
|
def user(self, value):
|
||||||
"""
|
"""
|
||||||
Sets the user on the current request. This is necessary to maintain
|
Sets the user on the current request. This is necessary to maintain
|
||||||
compatilbility with django.contrib.auth where the user proprety is
|
compatilbility with django.contrib.auth where the user proprety is
|
||||||
set in the login and logout functions.
|
set in the login and logout functions.
|
||||||
"""
|
"""
|
||||||
self._user = value
|
self._user = value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def auth(self):
|
def auth(self):
|
||||||
|
@ -206,6 +205,8 @@ class Request(object):
|
||||||
Return the instance of the authentication instance class that was used
|
Return the instance of the authentication instance class that was used
|
||||||
to authenticate the request, or `None`.
|
to authenticate the request, or `None`.
|
||||||
"""
|
"""
|
||||||
|
if not hasattr(self, '_authenticator'):
|
||||||
|
self._authenticator, self._user, self._auth = self._authenticate()
|
||||||
return self._authenticator
|
return self._authenticator
|
||||||
|
|
||||||
def _load_data_and_files(self):
|
def _load_data_and_files(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user