From 0a3e95ba2b3ff8ee8cb5259a219da42b56af5cd4 Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Sat, 23 May 2015 19:57:18 +0200 Subject: [PATCH] Then redirecting to login, keep service param --- cas_server/views.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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: