0001-custom_user-add-User.has_usable_password-48136.patch
src/authentic2/custom_user/models.py | ||
---|---|---|
30 | 30 |
from django.contrib.contenttypes.fields import GenericRelation |
31 | 31 |
except ImportError: |
32 | 32 |
from django.contrib.contenttypes.generic import GenericRelation |
33 |
from django.contrib.auth.hashers import identify_hasher |
|
34 |
from django.contrib.auth.hashers import UNUSABLE_PASSWORD_PREFIX |
|
33 | 35 |
from django.contrib.auth.models import AbstractBaseUser |
34 | 36 |
from django.contrib.postgres.fields import JSONField |
35 | 37 | |
... | ... | |
208 | 210 |
verbose_name_plural = _('users') |
209 | 211 |
ordering = ('last_name', 'first_name', 'email', 'username') |
210 | 212 | |
213 |
def has_usable_password(self): |
|
214 |
if (self.password is None or |
|
215 |
self.password.startswith(UNUSABLE_PASSWORD_PREFIX)): |
|
216 |
return False |
|
217 |
try: |
|
218 |
identify_hasher(self.password) |
|
219 |
except ValueError: |
|
220 |
return False |
|
221 |
return True |
|
222 | ||
211 | 223 |
def get_full_name(self): |
212 | 224 |
""" |
213 | 225 |
Returns the first_name plus the last_name, with a space in between. |
214 |
- |