mirror of
https://github.com/pinry/pinry.git
synced 2025-11-13 16:45:41 +01:00
close #203 : Add workaround for private settings and fix 500 error
This commit is contained in:
@@ -1,16 +1,15 @@
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseForbidden
|
||||||
from django.core.urlresolvers import reverse
|
|
||||||
|
|
||||||
|
|
||||||
class Public(object):
|
class Public(object):
|
||||||
|
|
||||||
|
acceptable_paths = (
|
||||||
|
"/api/v2/profile/",
|
||||||
|
)
|
||||||
|
|
||||||
def process_request(self, request):
|
def process_request(self, request):
|
||||||
if settings.PUBLIC is False and not request.user.is_authenticated():
|
if settings.PUBLIC is False and not request.user.is_authenticated():
|
||||||
acceptable_paths = [
|
for path in self.acceptable_paths:
|
||||||
'/login/',
|
if not request.path.startswith(path):
|
||||||
'/private/',
|
return HttpResponseForbidden()
|
||||||
'/register/',
|
|
||||||
]
|
|
||||||
if request.path not in acceptable_paths:
|
|
||||||
return HttpResponseRedirect(reverse('users:private'))
|
|
||||||
|
|||||||
Reference in New Issue
Block a user