From 3a3a044174bdc75f72165a7f7ba881955fbd7604 Mon Sep 17 00:00:00 2001 From: Bryan Date: Fri, 7 Feb 2014 02:09:06 -0500 Subject: [PATCH] Reworking logic of redirection, closes #320 --- karmaworld/utils/SSLRedirect.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/karmaworld/utils/SSLRedirect.py b/karmaworld/utils/SSLRedirect.py index 28cba2b..0a4a5df 100644 --- a/karmaworld/utils/SSLRedirect.py +++ b/karmaworld/utils/SSLRedirect.py @@ -13,6 +13,7 @@ SSL = 'SSL' class SSLRedirect(object): def process_view(self, request, view_func, view_args, view_kwargs): + # Does connection require security? if SSL in view_kwargs: secure = view_kwargs[SSL] del view_kwargs[SSL] @@ -22,7 +23,8 @@ class SSLRedirect(object): if request.user.is_authenticated(): secure = True - if not secure == self._is_secure(request): + # If connection is not secured but requires security, then redirect + if not self._is_secure(request) and secure: return self._redirect(request, secure) def _is_secure(self, request): -- 2.25.1