Ticket #3407: django_auth_views_login_provide_next.diff
File django_auth_views_login_provide_next.diff, 1.0 KB (added by , 18 years ago) |
---|
-
views.py
8 8 from django.contrib.auth.decorators import login_required 9 9 from django.contrib.auth import LOGIN_URL, REDIRECT_FIELD_NAME 10 10 11 def login(request, template_name='registration/login.html' ):11 def login(request, template_name='registration/login.html', default_next='/accounts/profile/'): 12 12 "Displays the login form and handles the login action." 13 13 manipulator = AuthenticationForm(request) 14 14 redirect_to = request.REQUEST.get(REDIRECT_FIELD_NAME, '') … … 17 17 if not errors: 18 18 # Light security check -- make sure redirect_to isn't garbage. 19 19 if not redirect_to or '://' in redirect_to or ' ' in redirect_to: 20 redirect_to = '/accounts/profile/'20 redirect_to = default_next 21 21 from django.contrib.auth import login 22 22 login(request, manipulator.get_user()) 23 23 request.session.delete_test_cookie()