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.http import HttpResponseRedirect
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.http import HttpResponseForbidden
|
||||
|
||||
|
||||
class Public(object):
|
||||
|
||||
acceptable_paths = (
|
||||
"/api/v2/profile/",
|
||||
)
|
||||
|
||||
def process_request(self, request):
|
||||
if settings.PUBLIC is False and not request.user.is_authenticated():
|
||||
acceptable_paths = [
|
||||
'/login/',
|
||||
'/private/',
|
||||
'/register/',
|
||||
]
|
||||
if request.path not in acceptable_paths:
|
||||
return HttpResponseRedirect(reverse('users:private'))
|
||||
for path in self.acceptable_paths:
|
||||
if not request.path.startswith(path):
|
||||
return HttpResponseForbidden()
|
||||
|
||||
Reference in New Issue
Block a user