aboutsummaryrefslogtreecommitdiff
path: root/app/dispatch/middleware.py
diff options
context:
space:
mode:
authorMitch Riedstra <mitch@riedstra.us>2017-11-10 20:44:21 -0500
committerMitch Riedstra <mitch@riedstra.us>2017-11-10 20:44:21 -0500
commit6155857dcd9a88d07756c465df42c5155c7183dc (patch)
treee0f59809d0b52410188b42d9b6be74abe17d8ce5 /app/dispatch/middleware.py
parent69d5a098f830128414f178d9382c65221f06e4bb (diff)
downloaddispatch-tracker-6155857dcd9a88d07756c465df42c5155c7183dc.tar.gz
dispatch-tracker-6155857dcd9a88d07756c465df42c5155c7183dc.tar.xz
User registration works. User invites work but has no UI
Diffstat (limited to 'app/dispatch/middleware.py')
-rw-r--r--app/dispatch/middleware.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/app/dispatch/middleware.py b/app/dispatch/middleware.py
index 8ae0465..a3b9ec6 100644
--- a/app/dispatch/middleware.py
+++ b/app/dispatch/middleware.py
@@ -1,9 +1,13 @@
from django.http import HttpResponseRedirect
from django.conf import settings
-from re import compile
-from django.core.urlresolvers import reverse
+import re
+from django.core.urlresolvers import reverse, reverse_lazy
-EXEMPT_URLS = [reverse('login'),reverse('logout')]
+EXEMPT_URLS = [
+ reverse('login'),
+ reverse('logout'),
+ ]
+EXEMPT_REGEX = re.compile('^/accounts/.*$')
if hasattr(settings, 'LOGIN_EXEMPT_URLS'):
EXEMPT_URLS += settings.LOGIN_EXEMPT_URLS
@@ -24,7 +28,10 @@ class LoginRequiredMiddleware(object):
def __call__(self, request):
if not request.user or not request.user.is_authenticated():
path = request.path_info
- if path not in EXEMPT_URLS:
+ # Check for any regex matches
+ reg = EXEMPT_REGEX.match(path)
+
+ if path not in EXEMPT_URLS and reg is None:
login_uri = '%s?next=%s' % (settings.LOGIN_URL, request.path_info)
return HttpResponseRedirect(login_uri)
else:
@@ -40,8 +47,3 @@ class LoginRequiredMiddleware(object):
return HttpResponseRedirect(allowed_paths[0])
return self.get_response(request)
-
-
- # TODO: Have the middleware automatically set the default identity
- # if not set and a superuser creates one
-