mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #31920 -- Made AuthenticationMiddleware add request.auser().
This commit is contained in:
parent
e83a88566a
commit
e846c5e724
5 changed files with 50 additions and 0 deletions
|
@ -281,9 +281,23 @@ middleware class is listed in :setting:`MIDDLEWARE`.
|
|||
else:
|
||||
... # Do something for anonymous users.
|
||||
|
||||
The :meth:`auser` method does the same thing but can be used from async
|
||||
contexts.
|
||||
|
||||
Methods
|
||||
-------
|
||||
|
||||
.. method:: HttpRequest.auser()
|
||||
|
||||
.. versionadded:: 5.0
|
||||
|
||||
From the :class:`~django.contrib.auth.middleware.AuthenticationMiddleware`:
|
||||
Coroutine. Returns an instance of :setting:`AUTH_USER_MODEL` representing
|
||||
the currently logged-in user. If the user isn't currently logged in,
|
||||
``auser`` will return an instance of
|
||||
:class:`~django.contrib.auth.models.AnonymousUser`. This is similar to the
|
||||
:attr:`user` attribute but it works in async contexts.
|
||||
|
||||
.. method:: HttpRequest.get_host()
|
||||
|
||||
Returns the originating host of the request using information from the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue