depot/web/quotes/quotesapp/middleware.py
Luke Granger-Brown ee3299223a web/quotes: require login for all pages
...except things under /accounts/, because I generally just trust that to do
access control for me.
2021-01-20 18:14:22 +00:00

15 lines
452 B
Python

from django.contrib.auth.decorators import login_required
class LoginRequiredMiddleware:
def __init__(self, get_response):
self.get_response = get_response
def is_open_url(self, path_info):
return path_info.startswith('/accounts/')
def __call__(self, request):
if not self.is_open_url(request.path_info):
return login_required()(self.get_response)(request)
return self.get_response(request)