Then redirecting to login, keep service param
This commit is contained in:
parent
b08d6a3f97
commit
0a3e95ba2b
@ -7,8 +7,10 @@ from django.conf import settings
|
|||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
|
from django.core.urlresolvers import reverse
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
import urllib
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
@ -24,6 +26,12 @@ def _logout(request):
|
|||||||
try: del request.session["warn"]
|
try: del request.session["warn"]
|
||||||
except KeyError: pass
|
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):
|
def login(request):
|
||||||
user = None
|
user = None
|
||||||
form = None
|
form = None
|
||||||
@ -63,7 +71,7 @@ def login(request):
|
|||||||
user = models.User.objects.get(username=request.session["username"])
|
user = models.User.objects.get(username=request.session["username"])
|
||||||
except models.User.DoesNotExist:
|
except models.User.DoesNotExist:
|
||||||
_logout(request)
|
_logout(request)
|
||||||
return redirect("login")
|
return redirect_params("login", params=dict(request.GET))
|
||||||
|
|
||||||
# if login agains a service is requestest
|
# if login agains a service is requestest
|
||||||
if service:
|
if service:
|
||||||
|
Loading…
Reference in New Issue
Block a user