From 92f48680dbd2e02f2b33f6ad0e35b7d337889fb2 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Sat, 27 Jan 2018 11:02:26 -0500 Subject: [PATCH] Expanded docs for AbstractBaseUser.has_usable_password(). --- django/contrib/auth/base_user.py | 5 +++++ docs/ref/contrib/auth.txt | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/django/contrib/auth/base_user.py b/django/contrib/auth/base_user.py index 0f8d5d87e2..357528e19e 100644 --- a/django/contrib/auth/base_user.py +++ b/django/contrib/auth/base_user.py @@ -115,6 +115,11 @@ class AbstractBaseUser(models.Model): self.password = make_password(None) 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) def get_session_auth_hash(self): diff --git a/docs/ref/contrib/auth.txt b/docs/ref/contrib/auth.txt index b3fca78d73..e05280367c 100644 --- a/docs/ref/contrib/auth.txt +++ b/docs/ref/contrib/auth.txt @@ -212,7 +212,9 @@ Methods Returns ``False`` if :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)