From f7e91cac689b28fc32ca52cdeac258ec0d58b4fc Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Wed, 24 Aug 2016 12:21:28 +0300 Subject: Fixed #27053 -- Documented contrib.auth.get_user(). --- docs/ref/contrib/auth.txt | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'docs/ref') diff --git a/docs/ref/contrib/auth.txt b/docs/ref/contrib/auth.txt index 69e3f40514..2ee6127622 100644 --- a/docs/ref/contrib/auth.txt +++ b/docs/ref/contrib/auth.txt @@ -682,3 +682,26 @@ The following backends are available in :mod:`django.contrib.auth.backends`: An :class:`~django.apps.AppConfig` for use if you :ref:`aren't using ` any of the built-in ``contrib.auth`` models. + +Utility functions +================= + +.. currentmodule:: django.contrib.auth + +.. function:: get_user(request) + + Returns the user model instance associated with the given ``request``’s + session. + + It checks if the authentication backend stored in the session is present in + :setting:`AUTHENTICATION_BACKENDS`. If so, it uses the backend's + ``get_user()`` method to retrieve the user model instance and then verifies + the session by calling the user model's + :meth:`~django.contrib.auth.models.AbstractBaseUser.get_session_auth_hash` + method. + + Returns an instance of :class:`~django.contrib.auth.models.AnonymousUser` + if the authentication backend stored in the session is no longer in + :setting:`AUTHENTICATION_BACKENDS`, if a user isn't returned by the + backend's ``get_user()`` method, or if the session auth hash doesn't + validate. -- cgit v1.3