From 15dc01a910b91330de051703ef9d1b24cab4d8d0 Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 3 Sep 2021 00:53:56 +0200 Subject: [PATCH] password overwrite --- InvenTree/InvenTree/urls.py | 3 ++- InvenTree/InvenTree/views.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py index de874193b1..6899452494 100644 --- a/InvenTree/InvenTree/urls.py +++ b/InvenTree/InvenTree/urls.py @@ -37,7 +37,7 @@ from rest_framework.documentation import include_docs_urls from .views import auth_request from .views import IndexView, SearchView, DatabaseStatsView -from .views import SettingsView, EditUserView, SetPasswordView, CustomEmailView, CustomConnectionsView +from .views import SettingsView, EditUserView, SetPasswordView, CustomEmailView, CustomConnectionsView, CustomPasswordChangeView from .views import CurrencyRefreshView from .views import AppearanceSelectView, SettingCategorySelectView from .views import DynamicJsView @@ -165,6 +165,7 @@ urlpatterns = [ # overrides of urlpatterns url(r'^accounts/email/', CustomEmailView.as_view(), name='account_email'), url(r'^accounts/social/connections/', CustomConnectionsView.as_view(), name='socialaccount_connections'), + url(r'^accounts/password/change/', CustomPasswordChangeView.as_view(), name='account_change_password'), url(r'^accounts/', include('allauth.urls')), # included urlpatterns ] diff --git a/InvenTree/InvenTree/views.py b/InvenTree/InvenTree/views.py index 9951bc992f..322781589b 100644 --- a/InvenTree/InvenTree/views.py +++ b/InvenTree/InvenTree/views.py @@ -27,7 +27,7 @@ from djmoney.contrib.exchange.models import ExchangeBackend, Rate from allauth.account.forms import AddEmailForm from allauth.socialaccount.forms import DisconnectForm from allauth.account.models import EmailAddress -from allauth.account.views import EmailView +from allauth.account.views import EmailView, PasswordChangeView from allauth.socialaccount.views import ConnectionsView from common.settings import currency_code_default, currency_codes @@ -849,6 +849,17 @@ class CustomConnectionsView(LoginRequiredMixin, ConnectionsView): return HttpResponseRedirect(self.success_url) +class CustomPasswordChangeView(LoginRequiredMixin, PasswordChangeView): + """ + Override of allauths PasswordChangeView to always show the settings but leave the functions allow + """ + success_url = reverse_lazy("settings") + + def get(self, request, *args, **kwargs): + # always redirect to settings + return HttpResponseRedirect(self.success_url) + + class CurrencyRefreshView(RedirectView): """ POST endpoint to refresh / update exchange rates