summaryrefslogtreecommitdiff
path: root/django/contrib
diff options
context:
space:
mode:
authorRoel Delos Reyes <badcoder28@gmail.com>2025-07-01 01:46:24 +0800
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-07-31 11:12:50 +0200
commit748ca0a146175c4868ece87f5e845a75416c30e3 (patch)
treee2ee97a9908c5ec3834cf55dcfdde0990656e0e7 /django/contrib
parent6ea331907996a51842da55c1f8d65eea7b367c7d (diff)
Fixed #36439 -- Optimized acheck_password by using sync_to_async on verify_password.
Diffstat (limited to 'django/contrib')
-rw-r--r--django/contrib/auth/hashers.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/django/contrib/auth/hashers.py b/django/contrib/auth/hashers.py
index 29eb1f1b77..4bb518cb89 100644
--- a/django/contrib/auth/hashers.py
+++ b/django/contrib/auth/hashers.py
@@ -6,6 +6,8 @@ import importlib
import math
import warnings
+from asgiref.sync import sync_to_async
+
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.core.signals import setting_changed
@@ -86,7 +88,10 @@ def check_password(password, encoded, setter=None, preferred="default"):
async def acheck_password(password, encoded, setter=None, preferred="default"):
"""See check_password()."""
- is_correct, must_update = verify_password(password, encoded, preferred=preferred)
+ is_correct, must_update = await sync_to_async(
+ verify_password,
+ thread_sensitive=False,
+ )(password, encoded, preferred=preferred)
if setter and is_correct and must_update:
await setter(password)
return is_correct