2021-01-20 18:14:22 +00:00
|
|
|
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):
|
2021-01-20 22:20:07 +00:00
|
|
|
return path_info.startswith("/accounts/")
|
2021-01-20 18:14:22 +00:00
|
|
|
|
|
|
|
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)
|