diff --git a/django/contrib/auth/hashers.py b/django/contrib/auth/hashers.py
index 96ec40b..18a11a4 100644
a
|
b
|
def reset_hashers(**kwargs):
|
27 | 27 | |
28 | 28 | |
29 | 29 | def is_password_usable(encoded): |
30 | | return (encoded is not None and encoded != UNUSABLE_PASSWORD) |
| 30 | if encoded is None or encoded == UNUSABLE_PASSWORD: |
| 31 | return False |
| 32 | try: |
| 33 | hasher = identify_hasher(encoded) |
| 34 | except ValueError: |
| 35 | return False |
| 36 | return True |
31 | 37 | |
32 | 38 | |
33 | 39 | def check_password(password, encoded, setter=None, preferred='default'): |
diff --git a/django/contrib/auth/tests/hashers.py b/django/contrib/auth/tests/hashers.py
index 673263b..cb9d97d 100644
a
|
b
|
class TestUtilsHashPass(unittest.TestCase):
|
100 | 100 | self.assertRaises(ValueError, doit) |
101 | 101 | self.assertRaises(ValueError, identify_hasher, "lolcat$salt$hash") |
102 | 102 | |
| 103 | def test_bad_encoded(self): |
| 104 | encoded = 'letmein_badencoded' |
| 105 | self.assertFalse(is_password_usable(encoded)) |
| 106 | |
103 | 107 | def test_low_level_pkbdf2(self): |
104 | 108 | hasher = PBKDF2PasswordHasher() |
105 | 109 | encoded = hasher.encode('letmein', 'seasalt') |