Skip to content

Commit 748ca0a

Browse files
roelzkie15sarahboyce
authored andcommitted
Fixed #36439 -- Optimized acheck_password by using sync_to_async on verify_password.
1 parent 6ea3319 commit 748ca0a

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

django/contrib/auth/hashers.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import math
77
import warnings
88

9+
from asgiref.sync import sync_to_async
10+
911
from django.conf import settings
1012
from django.core.exceptions import ImproperlyConfigured
1113
from django.core.signals import setting_changed
@@ -86,7 +88,10 @@ def check_password(password, encoded, setter=None, preferred="default"):
8688

8789
async def acheck_password(password, encoded, setter=None, preferred="default"):
8890
"""See check_password()."""
89-
is_correct, must_update = verify_password(password, encoded, preferred=preferred)
91+
is_correct, must_update = await sync_to_async(
92+
verify_password,
93+
thread_sensitive=False,
94+
)(password, encoded, preferred=preferred)
9095
if setter and is_correct and must_update:
9196
await setter(password)
9297
return is_correct

0 commit comments

Comments
 (0)