Ticket #3185: 3185_2.diff

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

use relative link, as mentioned in #3333

  • 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()
  • docs/authentication.txt

    === modified file 'docs/authentication.txt'
     
    377377
    378378``login_required`` does the following:
    379379
    380     * If the user isn't logged in, redirect to ``/accounts/login/``, passing
    381       the current absolute URL in the query string as ``next``. For example:
     380    * If the user isn't logged in, redirect to ``"settings.LOGIN_URL"``
     381      (``"/accounts/login/"`` by default), passing the current absolute URL
     382      in the query string as ``next``. For example:
    382383      ``/accounts/login/?next=/polls/3/``.
    383384    * If the user is logged in, execute the view normally. The view code is
    384385      free to assume the user is logged in.
    385386
    386 Note that you'll need to map the appropriate Django view to ``/accounts/login/``.
    387 To do this, add the following line to your URLconf::
     387Note that you'll need to map the appropriate Django view to ``"settings.LOGIN_URL"``.
     388For example, using the defaults, add the following line to your URLconf::
    388389
    389390    (r'^accounts/login/$', 'django.contrib.auth.views.login'),
    390391
     
    395396
    396397    * If called via ``POST``, it tries to log the user in. If login is
    397398      successful, the view redirects to the URL specified in ``next``. If
    398       ``next`` isn't provided, it redirects to ``/accounts/profile/`` (which is
    399       currently hard-coded). If login isn't successful, it redisplays the login
     399      ``next`` isn't provided, it redirects to ``"settings.ACCOUNT_URL"`` which
     400      defaults to ``/accounts/profile/``. If login isn't successful, it redisplays the login
    400401      form.
    401402
    402403It's your responsibility to provide the login form in a template called
  • docs/settings.txt

    === modified file 'docs/settings.txt'
     
    166166        'news.Story': lambda o: "/stories/%s/%s/" % (o.pub_year, o.slug),
    167167    }
    168168
     169ACCOUNT_URL
     170-------------
     171
     172Default: ``'/accounts/profile/'``
     173
     174The URL where requests are redirected after login when the ``"contrib.auth.login"`` view
     175gets no ``next`` parameter.
     176i.e.: When the `@login_required`_ decorator is called
     177
    169178ADMIN_FOR
    170179---------
    171180
     
    533542you'll have to remember to wrap the languages in the *real* ``gettext()`` in
    534543any code that uses ``LANGUAGES`` at runtime.
    535544
     545LOGIN_URL
     546-------------
     547
     548Default: ``'/accounts/login/'``
     549
     550The URL where requests are redirected for login, specially when using the
     551`@login_required`_ decorator.
     552
    536553MANAGERS
    537554--------
    538555
     
    967984
    968985It boils down to this: Use exactly one of either ``configure()`` or
    969986``DJANGO_SETTINGS_MODULE``. Not both, and not neither.
     987
     988.. _@login_required: ../authentication/#the-login-required-decorator
Back to Top