Ticket #11025: django-contrib-auth-absolute-login-url.2.patch
File django-contrib-auth-absolute-login-url.2.patch, 3.4 KB (added by , 15 years ago) |
---|
-
django/conf/global_settings.py
467 467 468 468 LOGIN_REDIRECT_URL = '/accounts/profile/' 469 469 470 REDIRECT_FIELD_NAME = 'next' 471 470 472 # The number of days a password reset link is valid for 471 473 PASSWORD_RESET_TIMEOUT_DAYS = 3 472 474 -
django/contrib/auth/views.py
92 92 "Redirects the user to the login page, passing the given 'next' page" 93 93 if not login_url: 94 94 login_url = settings.LOGIN_URL 95 return HttpResponseRedirect('%s?%s=%s' % (login_url, urlquote(redirect_field_name), urlquote(next))) 95 if '?' in login_url: 96 login_url += '&' 97 else: 98 login_url += '?' 99 return HttpResponseRedirect('%s%s=%s' % (login_url, urlquote(redirect_field_name), urlquote(next))) 96 100 97 101 # 4 views for password reset: 98 102 # - password_reset sends the mail -
django/contrib/auth/__init__.py
1 1 import datetime 2 2 from warnings import warn 3 from django.conf import settings 3 4 from django.core.exceptions import ImproperlyConfigured 4 5 from django.utils.importlib import import_module 5 6 6 7 SESSION_KEY = '_auth_user_id' 7 8 BACKEND_SESSION_KEY = '_auth_user_backend' 8 REDIRECT_FIELD_NAME = 'next'9 REDIRECT_FIELD_NAME = settings.REDIRECT_FIELD_NAME 9 10 10 11 def load_backend(path): 11 12 i = path.rfind('.') … … 35 36 return cls() 36 37 37 38 def get_backends(): 38 from django.conf import settings39 39 backends = [] 40 40 for backend_path in settings.AUTHENTICATION_BACKENDS: 41 41 backends.append(load_backend(backend_path)) -
django/contrib/auth/decorators.py
1 import urlparse 2 1 3 try: 2 4 from functools import update_wrapper, wraps 3 5 except ImportError: … … 22 24 def _wrapped_view(request, *args, **kwargs): 23 25 if test_func(request.user): 24 26 return view_func(request, *args, **kwargs) 25 path = urlquote(request.get_full_path()) 26 tup = login_url, redirect_field_name, path 27 return HttpResponseRedirect('%s?%s=%s' % tup) 27 url = urlparse.urlsplit(login_url) 28 scheme, hostname = url.scheme, url.netloc 29 if hostname.lower() == request.META['SERVER_NAME'].lower(): 30 retpath = urlquote(request.get_full_path()) 31 hostname = '' 32 scheme = '' 33 else: 34 retpath = urlquote(request.build_absolute_uri()) 35 query = url.query 36 if query: 37 query += '&' 38 query += '%s=%s' % (redirect_field_name, retpath) 39 return HttpResponseRedirect(urlparse.urlunsplit(urlparse.SplitResult( 40 scheme = scheme, 41 netloc = hostname, 42 path = url.path, 43 query = query, 44 fragment = '' 45 ))) 28 46 return wraps(view_func)(_wrapped_view) 29 47 return decorator 30 48