=== modified file 'django/conf/global_settings.py'
|
|
|
328 | 328 | |
329 | 329 | LOGIN_REDIRECT_URL = '/accounts/profile/' |
330 | 330 | |
| 331 | REDIRECT_FIELD_NAME = 'next' |
| 332 | |
331 | 333 | ########### |
332 | 334 | # TESTING # |
333 | 335 | ########### |
=== modified file 'django/contrib/auth/__init__.py'
|
|
|
3 | 3 | |
4 | 4 | SESSION_KEY = '_auth_user_id' |
5 | 5 | BACKEND_SESSION_KEY = '_auth_user_backend' |
6 | | REDIRECT_FIELD_NAME = 'next' |
7 | 6 | |
8 | 7 | def load_backend(path): |
9 | 8 | i = path.rfind('.') |
=== modified file 'django/contrib/auth/decorators.py'
|
|
|
1 | | from django.contrib.auth import REDIRECT_FIELD_NAME |
2 | 1 | from django.http import HttpResponseRedirect |
3 | 2 | from urllib import quote |
4 | 3 | |
… |
… |
|
8 | 7 | redirecting to the log-in page if necessary. The test should be a callable |
9 | 8 | that takes the user object and returns True if the user passes. |
10 | 9 | """ |
| 10 | from django.conf import settings |
11 | 11 | if not login_url: |
12 | | from django.conf import settings |
13 | 12 | login_url = settings.LOGIN_URL |
14 | 13 | def _dec(view_func): |
15 | 14 | def _checklogin(request, *args, **kwargs): |
16 | 15 | if test_func(request.user): |
17 | 16 | return view_func(request, *args, **kwargs) |
18 | | return HttpResponseRedirect('%s?%s=%s' % (login_url, REDIRECT_FIELD_NAME, quote(request.get_full_path()))) |
| 17 | return HttpResponseRedirect('%s?%s=%s' % (login_url, settings.REDIRECT_FIELD_NAME, quote(request.get_full_path()))) |
19 | 18 | _checklogin.__doc__ = view_func.__doc__ |
20 | 19 | _checklogin.__dict__ = view_func.__dict__ |
21 | 20 | |
=== modified file 'django/contrib/auth/views.py'
|
|
|
6 | 6 | from django.contrib.sites.models import Site, RequestSite |
7 | 7 | from django.http import HttpResponseRedirect |
8 | 8 | from django.contrib.auth.decorators import login_required |
9 | | from django.contrib.auth import REDIRECT_FIELD_NAME |
10 | 9 | from django.utils.translation import ugettext as _ |
11 | 10 | |
12 | 11 | def login(request, template_name='registration/login.html'): |
13 | 12 | "Displays the login form and handles the login action." |
14 | 13 | manipulator = AuthenticationForm(request) |
15 | | redirect_to = request.REQUEST.get(REDIRECT_FIELD_NAME, '') |
| 14 | from django.conf import settings |
| 15 | redirect_to = request.REQUEST.get(settings.REDIRECT_FIELD_NAME, '') |
16 | 16 | if request.POST: |
17 | 17 | errors = manipulator.get_validation_errors(request.POST) |
18 | 18 | if not errors: |
19 | 19 | # Light security check -- make sure redirect_to isn't garbage. |
20 | 20 | if not redirect_to or '//' in redirect_to or ' ' in redirect_to: |
21 | | from django.conf import settings |
22 | 21 | redirect_to = settings.LOGIN_REDIRECT_URL |
23 | 22 | from django.contrib.auth import login |
24 | 23 | login(request, manipulator.get_user()) |
… |
… |
|
35 | 34 | |
36 | 35 | return render_to_response(template_name, { |
37 | 36 | 'form': oldforms.FormWrapper(manipulator, request.POST, errors), |
38 | | REDIRECT_FIELD_NAME: redirect_to, |
| 37 | settings.REDIRECT_FIELD_NAME: redirect_to, |
39 | 38 | 'site_name': current_site.name, |
40 | 39 | }, context_instance=RequestContext(request)) |
41 | 40 | |
… |
… |
|
61 | 60 | if not login_url: |
62 | 61 | from django.conf import settings |
63 | 62 | login_url = settings.LOGIN_URL |
64 | | return HttpResponseRedirect('%s?%s=%s' % (login_url, REDIRECT_FIELD_NAME, next)) |
| 63 | return HttpResponseRedirect('%s?%s=%s' % (login_url, settings.REDIRECT_FIELD_NAME, next)) |
65 | 64 | |
66 | 65 | def password_reset(request, is_admin_site=False, template_name='registration/password_reset_form.html', |
67 | 66 | email_template_name='registration/password_reset_email.html'): |