diff options
-rw-r--r-- | servo/lib/middleware.py | 11 |
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 |