Logged-in hint middleware: fix bugs
This commit is contained in:
parent
71f98f19e7
commit
615b94e414
1 changed files with 3 additions and 1 deletions
|
@ -22,7 +22,7 @@ class LoggedInHintCookieMiddleware(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
if hasattr(settings, 'LOGGED_IN_HINT_COOKIE_NAME'):
|
if hasattr(settings, 'LOGGED_IN_HINT_COOKIE_NAME'):
|
||||||
self.cookie_name = settings.LOGGED_IN_HINT_COOKIE_NAME
|
self.cookie_name = settings.LOGGED_IN_HINT_COOKIE_NAME
|
||||||
else self.cookie_name = 'logged_in_hint'
|
else: self.cookie_name = 'logged_in_hint'
|
||||||
|
|
||||||
def process_request(self, request):
|
def process_request(self, request):
|
||||||
if not request.is_secure():
|
if not request.is_secure():
|
||||||
|
@ -31,6 +31,7 @@ class LoggedInHintCookieMiddleware(object):
|
||||||
url = HttpRequest.build_absolute_uri()
|
url = HttpRequest.build_absolute_uri()
|
||||||
assert url[:5] == 'http:'
|
assert url[:5] == 'http:'
|
||||||
return HttpResponseRedirect('https:' + url[5:])
|
return HttpResponseRedirect('https:' + url[5:])
|
||||||
|
return None
|
||||||
|
|
||||||
def process_response(self, request, response):
|
def process_response(self, request, response):
|
||||||
if request.is_secure():
|
if request.is_secure():
|
||||||
|
@ -41,6 +42,7 @@ class LoggedInHintCookieMiddleware(object):
|
||||||
response.set_cookie(self.cookie_name, value='True', expires=expiry, secure=False)
|
response.set_cookie(self.cookie_name, value='True', expires=expiry, secure=False)
|
||||||
else:
|
else:
|
||||||
response.delete_cookie(self.cookie_name)
|
response.delete_cookie(self.cookie_name)
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
class vzhled:
|
class vzhled:
|
||||||
|
|
Loading…
Reference in a new issue