Ticket #6340: logout_url.diff

File logout_url.diff, 2.3 KB (added by David Tulig, 16 years ago)

Adds LOGOUT_URL support to the logout view.

  • django/contrib/auth/views.py

    diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py
    index d3d8b4c..d194e0e 100644
    a b from django.http import HttpResponseRedirect  
    88from django.contrib.auth.decorators import login_required
    99from django.contrib.auth import REDIRECT_FIELD_NAME
    1010from django.utils.translation import ugettext as _
     11from django.conf import settings
    1112
    1213def login(request, template_name='registration/login.html', redirect_field_name=REDIRECT_FIELD_NAME):
    1314    "Displays the login form and handles the login action."
    def login(request, template_name='registration/login.html', redirect_field_name=  
    1819        if not errors:
    1920            # Light security check -- make sure redirect_to isn't garbage.
    2021            if not redirect_to or '//' in redirect_to or ' ' in redirect_to:
    21                 from django.conf import settings
    2222                redirect_to = settings.LOGIN_REDIRECT_URL
    2323            from django.contrib.auth import login
    2424            login(request, manipulator.get_user())
    def login(request, template_name='registration/login.html', redirect_field_name=  
    3939        'site_name': current_site.name,
    4040    }, context_instance=RequestContext(request))
    4141
    42 def logout(request, next_page=None, template_name='registration/logged_out.html'):
     42def logout(request, next_page=settings.LOGOUT_URL, template_name='registration/logged_out.html'):
    4343    "Logs out the user and displays 'You are logged out' message."
    4444    from django.contrib.auth import logout
    4545    logout(request)
    def logout(request, next_page=None, template_name='registration/logged_out.html'  
    5252def logout_then_login(request, login_url=None):
    5353    "Logs out the user if he is logged in. Then redirects to the log-in page."
    5454    if not login_url:
    55         from django.conf import settings
    5655        login_url = settings.LOGIN_URL
    5756    return logout(request, login_url)
    5857
    5958def redirect_to_login(next, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME):
    6059    "Redirects the user to the login page, passing the given 'next' page"
    6160    if not login_url:
    62         from django.conf import settings
    6361        login_url = settings.LOGIN_URL
    6462    return HttpResponseRedirect('%s?%s=%s' % (login_url, redirect_field_name, next))
    6563
Back to Top