diff options
| author | Mitch Riedstra <Mitch@riedstra.us> | 2017-11-07 13:02:09 -0500 |
|---|---|---|
| committer | Mitch Riedstra <Mitch@riedstra.us> | 2017-11-07 13:02:09 -0500 |
| commit | c055260bb88fd407c81ad0d40dd288a5aae4fb17 (patch) | |
| tree | 55e4786222eadd95c94407dda120815ff79dd068 /app/dispatch/middleware.py | |
| parent | 62f8c5e35949e41ecf777c36736bae1caa007179 (diff) | |
| download | dispatch-tracker-c055260bb88fd407c81ad0d40dd288a5aae4fb17.tar.gz dispatch-tracker-c055260bb88fd407c81ad0d40dd288a5aae4fb17.tar.xz | |
Updated middleware to force creation of user Identity. Fix issues with Identity creation. Added is_active to Django Admin UI for the dispatchAuth.models.User
Diffstat (limited to 'app/dispatch/middleware.py')
| -rw-r--r-- | app/dispatch/middleware.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/app/dispatch/middleware.py b/app/dispatch/middleware.py index 2b3e349..8ae0465 100644 --- a/app/dispatch/middleware.py +++ b/app/dispatch/middleware.py @@ -27,5 +27,21 @@ class LoginRequiredMiddleware(object): if path not in EXEMPT_URLS: login_uri = '%s?next=%s' % (settings.LOGIN_URL, request.path_info) return HttpResponseRedirect(login_uri) + else: + # I don't really like this but I don't really see a better + # way of checking for this + try: + identity = request.user.identity + except: + allowed_paths = [ reverse('identity_create', kwargs={'user_id': request.user.pk}) ] + allowed_paths.extend(EXEMPT_URLS) + print(allowed_paths) + if request.path_info not in allowed_paths: + 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 - return self.get_response(request)
\ No newline at end of file |
