Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Reset password hashers cache on settings_changed.

  • Loading branch information...
commit 2a09404792f9d369718143fdfbe9530fe2e60912 1 parent ddfc7c2
Anssi Kääriäinen authored April 30, 2012

Showing 1 changed file with 9 additions and 0 deletions. Show diff stats Hide diff stats

  1. 9  django/contrib/auth/hashers.py
9  django/contrib/auth/hashers.py
... ...
@@ -1,6 +1,8 @@
1 1
 import hashlib
2 2
 
  3
+from django.dispatch import receiver
3 4
 from django.conf import settings
  5
+from django.test.signals import setting_changed
4 6
 from django.utils import importlib
5 7
 from django.utils.datastructures import SortedDict
6 8
 from django.utils.encoding import smart_str
@@ -14,6 +16,13 @@
14 16
 HASHERS = None  # lazily loaded from PASSWORD_HASHERS
15 17
 PREFERRED_HASHER = None  # defaults to first item in PASSWORD_HASHERS
16 18
 
  19
+@receiver(setting_changed)
  20
+def reset_hashers(**kwargs):
  21
+    if kwargs['setting'] == 'PASSWORD_HASHERS':
  22
+        global HASHERS, PREFERRED_HASHER
  23
+        HASHERS = None
  24
+        PREFERRED_HASHER = None
  25
+
17 26
 
18 27
 def is_password_usable(encoded):
19 28
     return (encoded is not None and encoded != UNUSABLE_PASSWORD)

0 notes on commit 2a09404

Please sign in to comment.
Something went wrong with that request. Please try again.