From be31154a444d92496bb5c9b7502aaf53c4513959 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 10 May 2021 12:33:49 +1000 Subject: [PATCH] Cleaner implementation --- InvenTree/InvenTree/middleware.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/InvenTree/InvenTree/middleware.py b/InvenTree/InvenTree/middleware.py index 1f9aa23513..32ecd33b86 100644 --- a/InvenTree/InvenTree/middleware.py +++ b/InvenTree/InvenTree/middleware.py @@ -77,17 +77,17 @@ class AuthRequiredMiddleware(object): if request.path_info == reverse_lazy('logout'): return HttpResponseRedirect(reverse_lazy('login')) - login = reverse_lazy('login') - logout = reverse_lazy('logout') - path = request.path_info + # List of URL endpoints we *do not* want to redirect to urls = [ - login, - logout, + reverse_lazy('login'), + reverse_lazy('logout'), + reverse_lazy('admin:login'), + reverse_lazy('admin:logout'), ] - if path not in urls and not path.startswith('/api/') and '/admin/logout/' not in path: + if path not in urls and not path.startswith('/api/'): # Save the 'next' parameter to pass through to the login view return redirect('%s?next=%s' % (login, request.path))