Ticket #8906: 8906_auth_script_prefix.diff
File 8906_auth_script_prefix.diff, 3.4 KB (added by , 16 years ago) |
---|
-
django/contrib/auth/views.py
4 4 from django.contrib.auth.forms import AuthenticationForm 5 5 from django.contrib.auth.forms import PasswordResetForm, SetPasswordForm, PasswordChangeForm 6 6 from django.contrib.auth.tokens import default_token_generator 7 from django.core.urlresolvers import reverse 7 from django.core.urlresolvers import reverse, get_script_prefix 8 8 from django.shortcuts import render_to_response, get_object_or_404 9 9 from django.contrib.sites.models import Site, RequestSite 10 10 from django.http import HttpResponseRedirect, Http404 … … 22 22 if form.is_valid(): 23 23 # Light security check -- make sure redirect_to isn't garbage. 24 24 if not redirect_to or '//' in redirect_to or ' ' in redirect_to: 25 redirect_to = settings.LOGIN_REDIRECT_URL25 redirect_to = get_script_prefix() + settings.LOGIN_REDIRECT_URL 26 26 from django.contrib.auth import login 27 27 login(request, form.get_user()) 28 28 if request.session.test_cookie_worked(): … … 55 55 def logout_then_login(request, login_url=None): 56 56 "Logs out the user if he is logged in. Then redirects to the log-in page." 57 57 if not login_url: 58 login_url = settings.LOGIN_URL58 login_url = get_script_prefix() + settings.LOGIN_URL 59 59 return logout(request, login_url) 60 60 61 61 def redirect_to_login(next, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME): 62 62 "Redirects the user to the login page, passing the given 'next' page" 63 63 if not login_url: 64 login_url = settings.LOGIN_URL64 login_url = get_script_prefix() + settings.LOGIN_URL 65 65 return HttpResponseRedirect('%s?%s=%s' % (login_url, urlquote(redirect_field_name), urlquote(next))) 66 66 67 67 # 4 views for password reset: … … 135 135 136 136 def password_reset_complete(request, template_name='registration/password_reset_complete.html'): 137 137 return render_to_response(template_name, context_instance=RequestContext(request, 138 {'login_url': settings.LOGIN_URL}))138 {'login_url': get_script_prefix() + settings.LOGIN_URL})) 139 139 140 140 def password_change(request, template_name='registration/password_change_form.html', 141 141 post_change_redirect=None): -
django/contrib/auth/decorators.py
3 3 except ImportError: 4 4 from django.utils.functional import update_wrapper # Python 2.3, 2.4 fallback. 5 5 6 from django.core.urlresolvers import get_script_prefix 6 7 from django.contrib.auth import REDIRECT_FIELD_NAME 7 8 from django.http import HttpResponseRedirect 8 9 from django.utils.http import urlquote … … 51 52 def __init__(self, view_func, test_func, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME): 52 53 if not login_url: 53 54 from django.conf import settings 54 login_url = settings.LOGIN_URL55 login_url = get_script_prefix() + settings.LOGIN_URL 55 56 self.view_func = view_func 56 57 self.test_func = test_func 57 58 self.login_url = login_url