diff --git a/cas_server/views.py b/cas_server/views.py index 5572b1b..e043e1c 100644 --- a/cas_server/views.py +++ b/cas_server/views.py @@ -7,8 +7,10 @@ from django.conf import settings from django.contrib import messages from django.views.decorators.csrf import csrf_exempt from django.utils.translation import ugettext as _ +from django.core.urlresolvers import reverse import requests +import urllib from datetime import datetime, timedelta from lxml import etree @@ -24,6 +26,12 @@ def _logout(request): try: del request.session["warn"] except KeyError: pass + +def redirect_params(url_name, params={}): + url = reverse(url_name, args = args) + params = urllib.urlencode(params) + return HttpResponseRedirect(url + "?%s" % params) + def login(request): user = None form = None @@ -63,7 +71,7 @@ def login(request): user = models.User.objects.get(username=request.session["username"]) except models.User.DoesNotExist: _logout(request) - return redirect("login") + return redirect_params("login", params=dict(request.GET)) # if login agains a service is requestest if service: