From 6155857dcd9a88d07756c465df42c5155c7183dc Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Fri, 10 Nov 2017 20:44:21 -0500 Subject: User registration works. User invites work but has no UI --- app/dispatch/middleware.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'app/dispatch/middleware.py') 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 - -- cgit v1.2.3