Ticket #11025: django-contrib-auth-absolute-login-url.patch
File django-contrib-auth-absolute-login-url.patch, 3.0 KB (added by , 16 years ago) |
---|
-
django/conf/global_settings.py
374 374 375 375 LOGIN_REDIRECT_URL = '/accounts/profile/' 376 376 377 REDIRECT_FIELD_NAME = 'next' 378 377 379 # The number of days a password reset link is valid for 378 380 PASSWORD_RESET_TIMEOUT_DAYS = 3 379 381 -
django/contrib/auth/views.py
69 69 "Redirects the user to the login page, passing the given 'next' page" 70 70 if not login_url: 71 71 login_url = settings.LOGIN_URL 72 return HttpResponseRedirect('%s?%s=%s' % (login_url, urlquote(redirect_field_name), urlquote(next))) 72 if '?' in login_url: 73 login_url += '&' 74 else: 75 login_url += '?' 76 return HttpResponseRedirect('%s%s=%s' % (login_url, urlquote(redirect_field_name), urlquote(next))) 73 77 74 78 # 4 views for password reset: 75 79 # - password_reset sends the mail -
django/contrib/auth/__init__.py
1 1 import datetime 2 from django.conf import settings 2 3 from django.core.exceptions import ImproperlyConfigured 3 4 from django.utils.importlib import import_module 4 5 5 6 SESSION_KEY = '_auth_user_id' 6 7 BACKEND_SESSION_KEY = '_auth_user_backend' 7 REDIRECT_FIELD_NAME = 'next'8 REDIRECT_FIELD_NAME = settings.REDIRECT_FIELD_NAME 8 9 9 10 def load_backend(path): 10 11 i = path.rfind('.') … … 22 23 return cls() 23 24 24 25 def get_backends(): 25 from django.conf import settings26 26 backends = [] 27 27 for backend_path in settings.AUTHENTICATION_BACKENDS: 28 28 backends.append(load_backend(backend_path)) -
django/contrib/auth/decorators.py
1 import urlparse 1 2 try: 2 3 from functools import update_wrapper 3 4 except ImportError: … … 76 77 def __call__(self, request, *args, **kwargs): 77 78 if self.test_func(request.user): 78 79 return self.view_func(request, *args, **kwargs) 79 path = urlquote(request.get_full_path()) 80 tup = self.login_url, self.redirect_field_name, path 81 return HttpResponseRedirect('%s?%s=%s' % tup) 80 login_url = list(urlparse.urlparse(self.login_url)) 81 if login_url[1].lower() == request.META['SERVER_NAME'].lower(): 82 path = urlquote(request.get_full_path()) 83 login_url[1] = '' 84 else: 85 path = urlquote(request.build_absolute_uri()) 86 if login_url[4]: 87 login_url[4] += '&' 88 login_url[4] += '%s=%s' % (self.redirect_field_name, path) 89 return HttpResponseRedirect(urlparse.urlunparse(login_url))