Ticket #3185: login_url3.diff

File login_url3.diff, 1.6 KB (added by Gary Wilson <gary.wilson@…>, 18 years ago)

using getattr instead of try/except

  • django/contrib/auth/__init__.py

    === modified file 'django/contrib/auth/__init__.py'
     
     1from django.conf import settings
    12from django.core.exceptions import ImproperlyConfigured
    23
    34SESSION_KEY = '_auth_user_id'
    45BACKEND_SESSION_KEY = '_auth_user_backend'
    5 LOGIN_URL = '/accounts/login/'
     6LOGIN_URL = getattr(settings, 'LOGIN_URL', '/accounts/login/')
     7ACCOUNT_URL = getattr(settings, 'ACCOUNT_URL', '/accounts/profile/')
    68REDIRECT_FIELD_NAME = 'next'
    79
    810def load_backend(path):
  • django/contrib/auth/views.py

    === modified file 'django/contrib/auth/views.py'
     
    66from django.contrib.sites.models import Site
    77from django.http import HttpResponseRedirect
    88from django.contrib.auth.decorators import login_required
    9 from django.contrib.auth import LOGIN_URL, REDIRECT_FIELD_NAME
     9from django.contrib.auth import LOGIN_URL, ACCOUNT_URL, REDIRECT_FIELD_NAME
    1010
    1111def login(request, template_name='registration/login.html'):
    1212    "Displays the login form and handles the login action."
     
    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 = ACCOUNT_URL
    2121            from django.contrib.auth import login
    2222            login(request, manipulator.get_user())
    2323            request.session.delete_test_cookie()
Back to Top