mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Cleaner implementation
This commit is contained in:
parent
d9f621c922
commit
be31154a44
@ -77,17 +77,17 @@ class AuthRequiredMiddleware(object):
|
|||||||
if request.path_info == reverse_lazy('logout'):
|
if request.path_info == reverse_lazy('logout'):
|
||||||
return HttpResponseRedirect(reverse_lazy('login'))
|
return HttpResponseRedirect(reverse_lazy('login'))
|
||||||
|
|
||||||
login = reverse_lazy('login')
|
|
||||||
logout = reverse_lazy('logout')
|
|
||||||
|
|
||||||
path = request.path_info
|
path = request.path_info
|
||||||
|
|
||||||
|
# List of URL endpoints we *do not* want to redirect to
|
||||||
urls = [
|
urls = [
|
||||||
login,
|
reverse_lazy('login'),
|
||||||
logout,
|
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
|
# Save the 'next' parameter to pass through to the login view
|
||||||
|
|
||||||
return redirect('%s?next=%s' % (login, request.path))
|
return redirect('%s?next=%s' % (login, request.path))
|
||||||
|
Loading…
Reference in New Issue
Block a user