Fixed #31405 -- Added LoginRequiredMiddleware.

Co-authored-by: Adam Johnson <me@adamj.eu>
Co-authored-by: Mehmet İnce <mehmet@mehmetince.net>
Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>
This commit is contained in:
Hisham Mahmood 2024-05-05 11:21:28 +05:00 committed by Sarah Boyce
parent 7857507c7f
commit c7fc9f20b4
17 changed files with 633 additions and 12 deletions

View file

@ -656,8 +656,25 @@ inheritance list.
``is_active`` flag on a user, but the default
:setting:`AUTHENTICATION_BACKENDS` reject inactive users.
.. _disable-login-required-middleware-for-views:
.. currentmodule:: django.contrib.auth.decorators
The ``login_not_required`` decorator
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. versionadded:: 5.1
When :class:`~django.contrib.auth.middleware.LoginRequiredMiddleware` is
installed, all views require authentication by default. Some views, such as the
login view, may need to disable this behavior.
.. function:: login_not_required()
Allows unauthenticated requests without redirecting to the login page when
:class:`~django.contrib.auth.middleware.LoginRequiredMiddleware` is
installed.
Limiting access to logged-in users that pass a test
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~