Code

Ticket #3185: login_url2.diff

File login_url2.diff, 1.8 KB (added by Vasily Sulatskov <redvasily@…>, 8 years ago)
Line 
1Index: django/contrib/auth/views.py
2===================================================================
3--- django/contrib/auth/views.py        (revision 4256)
4+++ django/contrib/auth/views.py        (working copy)
5@@ -6,7 +6,7 @@
6 from django.contrib.sites.models import Site
7 from django.http import HttpResponseRedirect
8 from django.contrib.auth.decorators import login_required
9-from django.contrib.auth import LOGIN_URL, REDIRECT_FIELD_NAME
10+from django.contrib.auth import LOGIN_URL, REDIRECT_FIELD_NAME, ACCOUNT_URL
11 
12 def login(request, template_name='registration/login.html'):
13     "Displays the login form and handles the login action."
14@@ -17,7 +17,7 @@
15         if not errors:
16             # Light security check -- make sure redirect_to isn't garbage.
17             if not redirect_to or '://' in redirect_to or ' ' in redirect_to:
18-                redirect_to = '/accounts/profile/'
19+                redirect_to = ACCOUNT_URL
20             from django.contrib.auth import login
21             login(request, manipulator.get_user())
22             request.session.delete_test_cookie()
23Index: django/contrib/auth/__init__.py
24===================================================================
25--- django/contrib/auth/__init__.py     (revision 4256)
26+++ django/contrib/auth/__init__.py     (working copy)
27@@ -1,8 +1,20 @@
28 from django.core.exceptions import ImproperlyConfigured
29 
30+from django.conf import settings
31+
32 SESSION_KEY = '_auth_user_id'
33 BACKEND_SESSION_KEY = '_auth_user_backend'
34-LOGIN_URL = '/accounts/login/'
35+
36+try:
37+    LOGIN_URL = settings.LOGIN_URL
38+except AttributeError:
39+    LOGIN_URL = '/accounts/login/'
40+
41+try:
42+    ACCOUNT_URL = settings.ACCOUNT_URL
43+except AttributeError:
44+    ACCOUNT_URL = '/accounts/profile/'
45+
46 REDIRECT_FIELD_NAME = 'next'
47 
48 def load_backend(path):