Commit dcee1dfc authored by Hugo Osvaldo Barrera's avatar Hugo Osvaldo Barrera Committed by Tim Graham
Browse files

Fixed #12405 -- Added LOGOUT_REDIRECT_URL setting.

After a user logs out via auth.views.logout(), they're redirected
to LOGOUT_REDIRECT_URL if no `next_page` argument is provided.
parent ad216381
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -489,6 +489,8 @@ LOGIN_URL = '/accounts/login/'

LOGIN_REDIRECT_URL = '/accounts/profile/'

LOGOUT_REDIRECT_URL = None

# The number of days a password reset link is valid for
PASSWORD_RESET_TIMEOUT_DAYS = 3

+2 −0
Original line number Diff line number Diff line
@@ -104,6 +104,8 @@ def logout(request, next_page=None,

    if next_page is not None:
        next_page = resolve_url(next_page)
    elif settings.LOGOUT_REDIRECT_URL:
        next_page = resolve_url(settings.LOGOUT_REDIRECT_URL)

    if (redirect_field_name in request.POST or
            redirect_field_name in request.GET):
+20 −0
Original line number Diff line number Diff line
@@ -2642,6 +2642,26 @@ This setting also accepts view function names and :ref:`named URL patterns
<naming-url-patterns>` which can be used to reduce configuration duplication
since you don't have to define the URL in two places (``settings`` and URLconf).

.. setting:: LOGOUT_REDIRECT_URL

``LOGOUT_REDIRECT_URL``
-----------------------

.. versionadded:: 1.10

Default: ``None``

The URL where requests are redirected after a user logs out using the
:func:`~django.contrib.auth.views.logout` view (if the view doesn't get a
``next_page`` argument).

If ``None``, no redirect will be performed and the logout view will be
rendered.

This setting also accepts view function names and :ref:`named URL patterns
<naming-url-patterns>` which can be used to reduce configuration duplication
since you don't have to define the URL in two places (``settings`` and URLconf).

.. setting:: PASSWORD_RESET_TIMEOUT_DAYS

``PASSWORD_RESET_TIMEOUT_DAYS``
+4 −0
Original line number Diff line number Diff line
@@ -82,6 +82,10 @@ Minor features
* Added the optional ``backend`` argument to :func:`~django.contrib.auth.login`
  to allow using it without credentials.

* The new :setting:`LOGOUT_REDIRECT_URL` setting controls the redirect of the
  :func:`~django.contrib.auth.views.logout` view, if the view doesn't get a
  ``next_page`` argument.

:mod:`django.contrib.contenttypes`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+3 −1
Original line number Diff line number Diff line
@@ -1105,7 +1105,9 @@ implementation details see :ref:`using-the-views`.

    **Optional arguments:**

    * ``next_page``: The URL to redirect to after logout.
    * ``next_page``: The URL to redirect to after logout. Defaults to
      :setting:`settings.LOGOUT_REDIRECT_URL <LOGOUT_REDIRECT_URL>` if not
      supplied.

    * ``template_name``: The full name of a template to display after
      logging the user out. Defaults to
Loading