password overwrite

This commit is contained in:
Matthias 2021-09-03 00:53:56 +02:00
parent 849b71f7e4
commit 15dc01a910
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
2 changed files with 14 additions and 2 deletions

View File

@ -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
]

View File

@ -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