mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 13:05:42 +00:00
reimplement session ending
This commit is contained in:
@ -47,6 +47,7 @@ from .views import (
|
||||
AppearanceSelectView,
|
||||
CustomConnectionsView,
|
||||
CustomEmailView,
|
||||
CustomListUserSessionsView,
|
||||
CustomLoginView,
|
||||
CustomPasswordResetFromKeyView,
|
||||
DatabaseStatsView,
|
||||
@ -356,6 +357,12 @@ classic_frontendpatterns = [
|
||||
path('about/', AboutView.as_view(), name='about'),
|
||||
path('stats/', DatabaseStatsView.as_view(), name='stats'),
|
||||
# Single Sign On / allauth
|
||||
path(
|
||||
'accounts/sessions/',
|
||||
view=CustomListUserSessionsView.as_view(),
|
||||
name='usersessions_list',
|
||||
),
|
||||
path('accounts/', include('allauth.urls')),
|
||||
# overrides of urlpatterns
|
||||
path('accounts/email/', CustomEmailView.as_view(), name='account_email'),
|
||||
path(
|
||||
@ -392,21 +399,19 @@ frontendpatterns = []
|
||||
if settings.ENABLE_CLASSIC_FRONTEND:
|
||||
frontendpatterns += classic_frontendpatterns
|
||||
|
||||
# Add auth
|
||||
frontendpatterns += [
|
||||
path('accounts/', include('allauth.urls')) # Always needed as we need providers
|
||||
]
|
||||
|
||||
if settings.ENABLE_PLATFORM_FRONTEND:
|
||||
frontendpatterns += platform_urls
|
||||
if not settings.ENABLE_CLASSIC_FRONTEND:
|
||||
# Add a redirect for login views
|
||||
frontendpatterns += [
|
||||
path(
|
||||
'accounts/', include('allauth.urls')
|
||||
), # Still needed for provider login
|
||||
path(
|
||||
'accounts/login/',
|
||||
RedirectView.as_view(url=settings.FRONTEND_URL_BASE, permanent=False),
|
||||
name='account_login',
|
||||
)
|
||||
),
|
||||
]
|
||||
|
||||
urlpatterns += frontendpatterns
|
||||
|
@ -20,6 +20,7 @@ from allauth.account.models import EmailAddress
|
||||
from allauth.account.views import EmailView, LoginView, PasswordResetFromKeyView
|
||||
from allauth.socialaccount.forms import DisconnectForm
|
||||
from allauth.socialaccount.views import ConnectionsView
|
||||
from allauth.usersessions.views import ListUserSessionsView
|
||||
from djmoney.contrib.exchange.models import ExchangeBackend, Rate
|
||||
|
||||
import common.currency
|
||||
@ -582,6 +583,15 @@ class AboutView(AjaxView):
|
||||
ajax_form_title = _('About InvenTree')
|
||||
|
||||
|
||||
class CustomListUserSessionsView(ListUserSessionsView):
|
||||
"""A view to delete all other sessions."""
|
||||
|
||||
def form_valid(self, form):
|
||||
"""Delete all other sessions."""
|
||||
super().form_valid(form)
|
||||
return HttpResponseRedirect(reverse_lazy('settings'))
|
||||
|
||||
|
||||
class NotificationsView(TemplateView):
|
||||
"""View for showing notifications."""
|
||||
|
||||
|
@ -168,7 +168,7 @@
|
||||
{% include "spacer.html" %}
|
||||
<div class='btn-group' role='group'>
|
||||
{% if session_list.count > 1 %}
|
||||
<form method="post" action="{% url 'session_delete_other' %}">
|
||||
<form method="post" action="{% url 'usersessions_list' %}">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="btn btn-sm btn-default btn-danger" title='{% trans "Log out active sessions (except this one)" %}'>
|
||||
<span class='fas fa-sign-out-alt'></span> {% trans "Log Out Active Sessions" %}
|
||||
|
Reference in New Issue
Block a user