@@ -278,7 +278,8 @@ def user(self, value):
278
278
compatibility with django.contrib.auth where the user property is
279
279
set in the login and logout functions.
280
280
281
- Sets the user on the wrapped original request as well.
281
+ Note that we also set the user on Django's underlying `HttpRequest`
282
+ instance, ensuring that it is available to any middleware in the stack.
282
283
"""
283
284
self ._user = value
284
285
self ._request .user = value
@@ -300,6 +301,7 @@ def auth(self, value):
300
301
request, such as an authentication token.
301
302
"""
302
303
self ._auth = value
304
+ self ._request .auth = value
303
305
304
306
@property
305
307
def successful_authenticator (self ):
@@ -459,7 +461,7 @@ def _authenticate(self):
459
461
460
462
if user_auth_tuple is not None :
461
463
self ._authenticator = authenticator
462
- self .user , self ._auth = user_auth_tuple
464
+ self .user , self .auth = user_auth_tuple
463
465
return
464
466
465
467
self ._not_authenticated ()
@@ -479,9 +481,9 @@ def _not_authenticated(self):
479
481
self .user = None
480
482
481
483
if api_settings .UNAUTHENTICATED_TOKEN :
482
- self ._auth = api_settings .UNAUTHENTICATED_TOKEN ()
484
+ self .auth = api_settings .UNAUTHENTICATED_TOKEN ()
483
485
else :
484
- self ._auth = None
486
+ self .auth = None
485
487
486
488
def __getattr__ (self , attr ):
487
489
"""
0 commit comments