summaryrefslogtreecommitdiff
path: root/django/contrib/auth/base_user.py
diff options
context:
space:
mode:
authorHappyDingning <ssdyny@foxmail.com>2023-05-15 00:12:22 +0800
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-05-18 09:39:04 +0200
commit674c23999cb6982a9d447fedec4d72e135201fee (patch)
treeee9a368e355adca083a2a3583b06ba8a07c935fb /django/contrib/auth/base_user.py
parent4e73d8c04d15f9cbae067249c7ff39dec9d66eb1 (diff)
Fixed #34565 -- Added support for async checking of user passwords.
Diffstat (limited to 'django/contrib/auth/base_user.py')
-rw-r--r--django/contrib/auth/base_user.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/django/contrib/auth/base_user.py b/django/contrib/auth/base_user.py
index e205ccccf2..da0eac731f 100644
--- a/django/contrib/auth/base_user.py
+++ b/django/contrib/auth/base_user.py
@@ -8,6 +8,7 @@ import warnings
from django.conf import settings
from django.contrib.auth import password_validation
from django.contrib.auth.hashers import (
+ acheck_password,
check_password,
is_password_usable,
make_password,
@@ -122,6 +123,17 @@ class AbstractBaseUser(models.Model):
return check_password(raw_password, self.password, setter)
+ async def acheck_password(self, raw_password):
+ """See check_password()."""
+
+ async def setter(raw_password):
+ self.set_password(raw_password)
+ # Password hash upgrades shouldn't be considered password changes.
+ self._password = None
+ await self.asave(update_fields=["password"])
+
+ return await acheck_password(raw_password, self.password, setter)
+
def set_unusable_password(self):
# Set a value that will never be a valid hash
self.password = make_password(None)