diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py index fa6261ed80..1abb7b50ac 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, CustomPasswordChangeView +from .views import SettingsView, EditUserView, SetPasswordView, CustomEmailView, CustomConnectionsView, CustomPasswordChangeView, CustomPasswordResetFromKeyView from .views import CurrencyRefreshView from .views import AppearanceSelectView, SettingCategorySelectView from .views import DynamicJsView @@ -167,6 +167,7 @@ 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/password/reset/key/(?P[0-9A-Za-z]+)-(?P.+)/$", CustomPasswordResetFromKeyView.as_view(), name="account_reset_password_from_key"), url(r'^accounts/', include('allauth.urls')), # included urlpatterns ] diff --git a/InvenTree/InvenTree/views.py b/InvenTree/InvenTree/views.py index adcf923ed2..14de376d25 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, PasswordChangeView +from allauth.account.views import EmailView, PasswordChangeView, PasswordResetFromKeyView from allauth.socialaccount.views import ConnectionsView from common.settings import currency_code_default, currency_codes @@ -857,6 +857,13 @@ class CustomPasswordChangeView(LoginRequiredMixin, PasswordChangeView): success_url = reverse_lazy("login") +class CustomPasswordResetFromKeyView(PasswordResetFromKeyView): + """ + Override of allauths PasswordResetFromKeyView to always show the settings but leave the functions allow + """ + success_url = reverse_lazy("account_login") + + class CurrencyRefreshView(RedirectView): """ POST endpoint to refresh / update exchange rates diff --git a/InvenTree/templates/account/password_reset_from_key.html b/InvenTree/templates/account/password_reset_from_key.html new file mode 100644 index 0000000000..f9fa339983 --- /dev/null +++ b/InvenTree/templates/account/password_reset_from_key.html @@ -0,0 +1,23 @@ +{% extends "account/base.html" %} + +{% load i18n crispy_forms_tags %} +{% block head_title %}{% trans "Change Password" %}{% endblock %} + +{% block content %} +

{% if token_fail %}{% trans "Bad Token" %}{% else %}{% trans "Change Password" %}{% endif %}

+ + {% if token_fail %} + {% url 'account_reset_password' as passwd_reset_url %} +

{% blocktrans %}The password reset link was invalid, possibly because it has already been used. Please request a new password reset.{% endblocktrans %}

+ {% else %} + {% if form %} +
+ {% csrf_token %} + {{ form|crispy }} + +
+ {% else %} +

{% trans 'Your password is now changed.' %}

+ {% endif %} + {% endif %} +{% endblock %}