From d9f621c9226d1a087774362501e9ceced2098581 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 10 May 2021 12:29:51 +1000 Subject: [PATCH] Login redirect fix --- InvenTree/InvenTree/middleware.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/InvenTree/InvenTree/middleware.py b/InvenTree/InvenTree/middleware.py index f30d77ad3b..1f9aa23513 100644 --- a/InvenTree/InvenTree/middleware.py +++ b/InvenTree/InvenTree/middleware.py @@ -78,8 +78,16 @@ class AuthRequiredMiddleware(object): return HttpResponseRedirect(reverse_lazy('login')) login = reverse_lazy('login') + logout = reverse_lazy('logout') - if not request.path_info == login and not request.path_info.startswith('/api/'): + path = request.path_info + + urls = [ + login, + logout, + ] + + if path not in urls and not path.startswith('/api/') and '/admin/logout/' not in path: # Save the 'next' parameter to pass through to the login view return redirect('%s?next=%s' % (login, request.path))