aboutsummaryrefslogtreecommitdiffstats
path: root/servo
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2021-05-12 21:10:25 +0300
committerFilipp Lepalaan <filipp@mac.com>2021-05-12 21:10:25 +0300
commite01e9c6fbd3e76aeef643afa36b5ab52d2f03b09 (patch)
tree12585be55b00d704039cd43d40921e13ea0e2476 /servo
parent64babb6918fe038e8a94353117fb869e4db41f02 (diff)
downloadServo-e01e9c6fbd3e76aeef643afa36b5ab52d2f03b09.tar.gz
Servo-e01e9c6fbd3e76aeef643afa36b5ab52d2f03b09.tar.bz2
Servo-e01e9c6fbd3e76aeef643afa36b5ab52d2f03b09.zip
Fix middleware
Diffstat (limited to 'servo')
-rw-r--r--servo/lib/middleware.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/servo/lib/middleware.py b/servo/lib/middleware.py
index 6549e6a..6eadead 100644
--- a/servo/lib/middleware.py
+++ b/servo/lib/middleware.py
@@ -25,17 +25,18 @@ class LoginRequiredMiddleware:
self.get_response = get_response
def __call__(self, request):
- response = self.get_response(request)
-
assert hasattr(request, 'user'), "The Login Required middleware\
requires authentication middleware to be installed. Edit your\
- MIDDLEWARE_CLASSES setting to insert\
+ MIDDLEWARE setting to insert\
'django.contrib.auth.middlware.AuthenticationMiddleware'. If that doesn't\
work, ensure your TEMPLATE_CONTEXT_PROCESSORS setting includes\
'django.core.context_processors.auth'."
- if request.user.is_authenticated == False:
+
+ response = self.get_response(request)
+
+ if not request.user.is_authenticated:
path = request.path_info.lstrip('/')
- if any(m.match(path) for m in EXEMPT_URLS) == False:
+ if not any(m.match(path) for m in EXEMPT_URLS):
return HttpResponseRedirect(settings.LOGIN_URL)
return response