Ticket #3407: django_auth_views_login_provide_next.diff

File django_auth_views_login_provide_next.diff, 1.0 KB (added by imbaczek@…, 9 years ago)

default_next login view parameter

  • views.py

     
    88from django.contrib.auth.decorators import login_required
    99from django.contrib.auth import LOGIN_URL, REDIRECT_FIELD_NAME
    1010
    11 def login(request, template_name='registration/login.html'):
     11def login(request, template_name='registration/login.html', default_next='/accounts/profile/'):
    1212    "Displays the login form and handles the login action."
    1313    manipulator = AuthenticationForm(request)
    1414    redirect_to = request.REQUEST.get(REDIRECT_FIELD_NAME, '')
     
    1717        if not errors:
    1818            # Light security check -- make sure redirect_to isn't garbage.
    1919            if not redirect_to or '://' in redirect_to or ' ' in redirect_to:
    20                 redirect_to = '/accounts/profile/'
     20                redirect_to = default_next
    2121            from django.contrib.auth import login
    2222            login(request, manipulator.get_user())
    2323            request.session.delete_test_cookie()
Back to Top