Ticket #10857: redirect_on_exiting_auth.diff
File redirect_on_exiting_auth.diff, 1.3 KB (added by , 16 years ago) |
---|
-
django/contrib/auth/views.py
17 17 def login(request, template_name='registration/login.html', redirect_field_name=REDIRECT_FIELD_NAME): 18 18 "Displays the login form and handles the login action." 19 19 redirect_to = request.REQUEST.get(redirect_field_name, '') 20 # Light security check -- make sure redirect_to isn't garbage. 21 if not redirect_to or '//' in redirect_to or ' ' in redirect_to: 22 redirect_to = settings.LOGIN_REDIRECT_URL 23 # if already authenticated just redirect 24 if request.user and request.user.is_authenticated(): 25 return HttpResponseRedirect(settings.LOGIN_REDIRECT_URL) 20 26 if request.method == "POST": 21 27 form = AuthenticationForm(data=request.POST) 22 28 if form.is_valid(): 23 # Light security check -- make sure redirect_to isn't garbage.24 if not redirect_to or '//' in redirect_to or ' ' in redirect_to:25 redirect_to = settings.LOGIN_REDIRECT_URL26 29 from django.contrib.auth import login 27 30 login(request, form.get_user()) 28 31 if request.session.test_cookie_worked():