From: Alex Dehnert Date: Sun, 30 May 2010 02:34:45 +0000 (-0400) Subject: localhost check needs to use portless-HTTP_HOST X-Git-Url: https://snippets.scripts.mit.edu/gitweb.cgi/Scripts/git/.git/commitdiff_plain/6e5f75cd24ff17ae694e385aa066f34a0d325e1f localhost check needs to use portless-HTTP_HOST As a bonus, this gets around the problem that the Django dev server doesn't set REQUEST_URI. --- diff --git a/django/mit/__init__.py b/django/mit/__init__.py index 8858248..8f785ae 100644 --- a/django/mit/__init__.py +++ b/django/mit/__init__.py @@ -46,7 +46,8 @@ class ScriptsRemoteUserBackend(RemoteUserBackend): return user def scripts_login(request, **kwargs): - if request.META['HTTP_HOST'] == 'localhost': + host = request.META['HTTP_HOST'].split(':')[0] + if host == 'localhost': return login(request, **kwargs) elif request.META['SERVER_PORT'] == '444': if request.user.is_authenticated(): @@ -64,6 +65,5 @@ def scripts_login(request, **kwargs): return login(request, **kwargs) else: # Move to port 444 - host = request.META['HTTP_HOST'].split(':')[0] redirect_to = "https://%s:444%s" % (host, request.META['REQUEST_URI'], ) return HttpResponseRedirect(redirect_to)