Code

Ticket #3185: login_url3.diff

File login_url3.diff, 1.6 KB (added by Gary Wilson <gary.wilson@…>, 7 years ago)

using getattr instead of try/except

Line 
1=== modified file 'django/contrib/auth/__init__.py'
2--- django/contrib/auth/__init__.py     2006-12-19 04:35:09 +0000
3+++ django/contrib/auth/__init__.py     2007-01-18 01:42:17 +0000
4@@ -1,8 +1,10 @@
5+from django.conf import settings
6 from django.core.exceptions import ImproperlyConfigured
7 
8 SESSION_KEY = '_auth_user_id'
9 BACKEND_SESSION_KEY = '_auth_user_backend'
10-LOGIN_URL = '/accounts/login/'
11+LOGIN_URL = getattr(settings, 'LOGIN_URL', '/accounts/login/')
12+ACCOUNT_URL = getattr(settings, 'ACCOUNT_URL', '/accounts/profile/')
13 REDIRECT_FIELD_NAME = 'next'
14 
15 def load_backend(path):
16
17=== modified file 'django/contrib/auth/views.py'
18--- django/contrib/auth/views.py        2006-12-19 04:35:09 +0000
19+++ django/contrib/auth/views.py        2007-01-18 01:43:37 +0000
20@@ -6,7 +6,7 @@
21 from django.contrib.sites.models import Site
22 from django.http import HttpResponseRedirect
23 from django.contrib.auth.decorators import login_required
24-from django.contrib.auth import LOGIN_URL, REDIRECT_FIELD_NAME
25+from django.contrib.auth import LOGIN_URL, ACCOUNT_URL, REDIRECT_FIELD_NAME
26 
27 def login(request, template_name='registration/login.html'):
28     "Displays the login form and handles the login action."
29@@ -17,7 +17,7 @@
30         if not errors:
31             # Light security check -- make sure redirect_to isn't garbage.
32             if not redirect_to or '://' in redirect_to or ' ' in redirect_to:
33-                redirect_to = '/accounts/profile/'
34+                redirect_to = ACCOUNT_URL
35             from django.contrib.auth import login
36             login(request, manipulator.get_user())
37             request.session.delete_test_cookie()
38