Files
Pinry/users/middleware.py

17 lines
493 B
Python
Raw Normal View History

2012-08-01 21:30:18 +00:00
from django.conf import settings
from django.http import HttpResponseForbidden
from django.utils.deprecation import MiddlewareMixin
2012-08-01 21:30:18 +00:00
class Public(MiddlewareMixin):
2019-02-22 17:40:02 +08:00
acceptable_paths = (
"/api/v2/profile/",
)
2012-08-01 21:30:18 +00:00
def process_request(self, request):
if settings.PUBLIC is False and not request.user.is_authenticated:
for path in self.acceptable_paths:
if not request.path.startswith(path):
return HttpResponseForbidden()