Skip to content

Commit cd7554e

Browse files
Xdynixsarahboyce
authored andcommitted
Fixed #36561 -- Used request.auser() in contrib.auth.aupdate_session_auth_hash().
1 parent bcddf64 commit cd7554e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

django/contrib/auth/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,5 +408,5 @@ def update_session_auth_hash(request, user):
408408
async def aupdate_session_auth_hash(request, user):
409409
"""See update_session_auth_hash()."""
410410
await request.session.acycle_key()
411-
if hasattr(user, "get_session_auth_hash") and request.user == user:
411+
if hasattr(user, "get_session_auth_hash") and await request.auser() == user:
412412
await request.session.aset(HASH_SESSION_KEY, user.get_session_auth_hash())

tests/async/test_async_auth.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,11 @@ async def test_change_password(self):
143143
await self.client.alogin(username="testuser", password="testpw")
144144
request = HttpRequest()
145145
request.session = await self.client.asession()
146-
request.user = self.test_user
146+
147+
async def auser():
148+
return self.test_user
149+
150+
request.auser = auser
147151
await aupdate_session_auth_hash(request, self.test_user)
148152
user = await aget_user(request)
149153
self.assertIsInstance(user, User)

0 commit comments

Comments
 (0)