Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Reset password hashers cache on settings_changed.

  • Loading branch information...
commit 2a09404792f9d369718143fdfbe9530fe2e60912 1 parent ddfc7c2
@akaariai akaariai authored
Showing with 9 additions and 0 deletions.
  1. +9 −0 django/contrib/auth/hashers.py
View
9 django/contrib/auth/hashers.py
@@ -1,6 +1,8 @@
import hashlib
+from django.dispatch import receiver
from django.conf import settings
+from django.test.signals import setting_changed
from django.utils import importlib
from django.utils.datastructures import SortedDict
from django.utils.encoding import smart_str
@@ -14,6 +16,13 @@
HASHERS = None # lazily loaded from PASSWORD_HASHERS
PREFERRED_HASHER = None # defaults to first item in PASSWORD_HASHERS
+@receiver(setting_changed)
+def reset_hashers(**kwargs):
+ if kwargs['setting'] == 'PASSWORD_HASHERS':
+ global HASHERS, PREFERRED_HASHER
+ HASHERS = None
+ PREFERRED_HASHER = None
+
def is_password_usable(encoded):
return (encoded is not None and encoded != UNUSABLE_PASSWORD)
Please sign in to comment.
Something went wrong with that request. Please try again.