Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Use templated mail in password reset view
Anna Siwik57cc45463096
diff --git a/saleor/registration/forms.py b/saleor/registration/forms.pyindex 43744ad6e9..17a9017ca7 100644--- a/saleor/registration/forms.py+++ b/saleor/registration/forms.py@@ -5,6 +5,7 @@ from django.urls import reversefrom django.utils.translation import pgettext, pgettext_lazyfrom templated_email import send_templated_mail+from ..core.utils import build_absolute_urifrom ..userprofile.models import User@@ -69,3 +70,24 @@ class PasswordSetUpForm(django_forms.PasswordResetForm):send_templated_mail('account/password_set', from_email=from_email,recipient_list=[to_email], context=context)+++class PasswordResetForm(django_forms.PasswordResetForm):+ """PasswordResetForm that overrides sending emails to use templated email.+ """++ def get_users(self, email):+ active_users = User.objects.filter(email__iexact=email, is_active=True)+ return active_users++ def send_mail(+ self, subject_template_name, email_template_name, context,+ from_email, to_email, html_email_template_name=None):+ reset_url = build_absolute_uri(+ reverse(+ 'account_reset_password_confirm',+ kwargs={'uidb64': context['uid'], 'token': context['token']}))+ context['reset_url'] = reset_url+ send_templated_mail(+ 'account/password_reset', from_email=from_email,+ recipient_list=[to_email], context=context)diff --git a/saleor/registration/views.py b/saleor/registration/views.pyindex 8b5967415c..44f203cf58 100644--- a/saleor/registration/views.py+++ b/saleor/registration/views.py@@ -8,7 +8,7 @@ from django.urls import reverse_lazyfrom django.utils.translation import ugettext_lazy as _from ..cart.utils import find_and_assign_anonymous_cart-from .forms import LoginForm, PasswordSetUpForm, SignupForm+from .forms import LoginForm, PasswordResetForm, PasswordSetUpForm, SignupForm@find_and_assign_anonymous_cart()@@ -47,8 +47,7 @@ def password_reset(request):kwargs = {'template_name': 'account/password_reset.html','success_url': reverse_lazy('account_reset_password_done'),- 'email_template_name': 'account/email/password_reset_message.txt',- 'subject_template_name': 'account/email/password_reset_subject.txt'}+ 'form_class': PasswordResetForm}return django_views.PasswordResetView.as_view(**kwargs)(request, **kwargs)