mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-03-03 10:45:51 +03:00
Set user on wrapped request
This commit is contained in:
parent
caf1de3b88
commit
85c96bb574
|
@ -277,8 +277,11 @@ class Request(object):
|
||||||
Sets the user on the current request. This is necessary to maintain
|
Sets the user on the current request. This is necessary to maintain
|
||||||
compatibility with django.contrib.auth where the user property is
|
compatibility with django.contrib.auth where the user property is
|
||||||
set in the login and logout functions.
|
set in the login and logout functions.
|
||||||
|
|
||||||
|
Sets the user on the wrapped original request as well.
|
||||||
"""
|
"""
|
||||||
self._user = value
|
self._user = value
|
||||||
|
self._request.user = value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def auth(self):
|
def auth(self):
|
||||||
|
@ -456,7 +459,7 @@ class Request(object):
|
||||||
|
|
||||||
if user_auth_tuple is not None:
|
if user_auth_tuple is not None:
|
||||||
self._authenticator = authenticator
|
self._authenticator = authenticator
|
||||||
self._user, self._auth = user_auth_tuple
|
self.user, self._auth = user_auth_tuple
|
||||||
return
|
return
|
||||||
|
|
||||||
self._not_authenticated()
|
self._not_authenticated()
|
||||||
|
@ -471,9 +474,9 @@ class Request(object):
|
||||||
self._authenticator = None
|
self._authenticator = None
|
||||||
|
|
||||||
if api_settings.UNAUTHENTICATED_USER:
|
if api_settings.UNAUTHENTICATED_USER:
|
||||||
self._user = api_settings.UNAUTHENTICATED_USER()
|
self.user = api_settings.UNAUTHENTICATED_USER()
|
||||||
else:
|
else:
|
||||||
self._user = None
|
self.user = None
|
||||||
|
|
||||||
if api_settings.UNAUTHENTICATED_TOKEN:
|
if api_settings.UNAUTHENTICATED_TOKEN:
|
||||||
self._auth = api_settings.UNAUTHENTICATED_TOKEN()
|
self._auth = api_settings.UNAUTHENTICATED_TOKEN()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user