mirror of https://github.com/django/django.git
Reset password hashers cache on settings_changed.
This commit is contained in:
parent
ddfc7c2530
commit
2a09404792
|
@ -1,6 +1,8 @@
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
|
from django.dispatch import receiver
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.test.signals import setting_changed
|
||||||
from django.utils import importlib
|
from django.utils import importlib
|
||||||
from django.utils.datastructures import SortedDict
|
from django.utils.datastructures import SortedDict
|
||||||
from django.utils.encoding import smart_str
|
from django.utils.encoding import smart_str
|
||||||
|
@ -14,6 +16,13 @@ UNUSABLE_PASSWORD = '!' # This will never be a valid encoded hash
|
||||||
HASHERS = None # lazily loaded from PASSWORD_HASHERS
|
HASHERS = None # lazily loaded from PASSWORD_HASHERS
|
||||||
PREFERRED_HASHER = None # defaults to first item in 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):
|
def is_password_usable(encoded):
|
||||||
return (encoded is not None and encoded != UNUSABLE_PASSWORD)
|
return (encoded is not None and encoded != UNUSABLE_PASSWORD)
|
||||||
|
|
Loading…
Reference in New Issue