Skip to content

Commit 85c96bb

Browse files
Set user on wrapped request
1 parent caf1de3 commit 85c96bb

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

rest_framework/request.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,11 @@ def user(self, value):
277277
Sets the user on the current request. This is necessary to maintain
278278
compatibility with django.contrib.auth where the user property is
279279
set in the login and logout functions.
280+
281+
Sets the user on the wrapped original request as well.
280282
"""
281283
self._user = value
284+
self._request.user = value
282285

283286
@property
284287
def auth(self):
@@ -456,7 +459,7 @@ def _authenticate(self):
456459

457460
if user_auth_tuple is not None:
458461
self._authenticator = authenticator
459-
self._user, self._auth = user_auth_tuple
462+
self.user, self._auth = user_auth_tuple
460463
return
461464

462465
self._not_authenticated()
@@ -471,9 +474,9 @@ def _not_authenticated(self):
471474
self._authenticator = None
472475

473476
if api_settings.UNAUTHENTICATED_USER:
474-
self._user = api_settings.UNAUTHENTICATED_USER()
477+
self.user = api_settings.UNAUTHENTICATED_USER()
475478
else:
476-
self._user = None
479+
self.user = None
477480

478481
if api_settings.UNAUTHENTICATED_TOKEN:
479482
self._auth = api_settings.UNAUTHENTICATED_TOKEN()

0 commit comments

Comments
 (0)