Expanded docs for AbstractBaseUser.has_usable_password().

This commit is contained in:
Tim Graham 2018-01-27 11:02:26 -05:00
parent a455e732a0
commit 92f48680db
2 changed files with 8 additions and 1 deletions

View File

@ -115,6 +115,11 @@ class AbstractBaseUser(models.Model):
self.password = make_password(None) self.password = make_password(None)
def has_usable_password(self): def has_usable_password(self):
"""
Return False if set_unusable_password() has been called for this user,
or if the password is None, or if the password uses a hasher that's not
in the PASSWORD_HASHERS setting.
"""
return is_password_usable(self.password) return is_password_usable(self.password)
def get_session_auth_hash(self): def get_session_auth_hash(self):

View File

@ -212,7 +212,9 @@ Methods
Returns ``False`` if Returns ``False`` if
:meth:`~django.contrib.auth.models.User.set_unusable_password()` has :meth:`~django.contrib.auth.models.User.set_unusable_password()` has
been called for this user. been called for this user, or if the password is ``None``, or if the
password uses a hasher that's not in the :setting:`PASSWORD_HASHERS`
setting.
.. method:: get_group_permissions(obj=None) .. method:: get_group_permissions(obj=None)