From 3e472f3b18c7f0c5fde39e40c855b2de2036f64f Mon Sep 17 00:00:00 2001 From: Eve Martin Date: Wed, 10 Apr 2024 10:18:30 +0000 Subject: [PATCH] fix: move reset password email --- cfl_common/common/mail.py | 1 + portal/forms/registration.py | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cfl_common/common/mail.py b/cfl_common/common/mail.py index 62d6ac16c..91cef7c96 100644 --- a/cfl_common/common/mail.py +++ b/cfl_common/common/mail.py @@ -8,6 +8,7 @@ campaign_ids = { "email_change_notification": 1551600, "email_change_verification": 1551594, + "reset_password": 1557153, "verify_new_user": 1551577, "verify_new_user_first_reminder": 1557170, "verify_new_user_second_reminder": 1557173, diff --git a/portal/forms/registration.py b/portal/forms/registration.py index 8fee3053d..0c8451112 100644 --- a/portal/forms/registration.py +++ b/portal/forms/registration.py @@ -2,14 +2,17 @@ from captcha.widgets import ReCaptchaV2Invisible from common.email_messages import resetEmailPasswordMessage from common.helpers.emails import NOTIFICATION_EMAIL, send_email +from common.mail import campaign_ids, send_dotdigital_email from common.models import Student, Teacher from django import forms from django.contrib.auth import forms as django_auth_forms from django.contrib.auth import get_user_model from django.contrib.auth.tokens import default_token_generator from django.contrib.sites.shortcuts import get_current_site +from django.urls import reverse_lazy from django.utils.encoding import force_bytes from django.utils.http import urlsafe_base64_encode + from portal.helpers.password import PasswordStrength, form_clean_password @@ -88,16 +91,16 @@ def save( "protocol": self._compute_protocol(use_https), } - email_subject_content = resetEmailPasswordMessage( - request, domain, context["uid"], context["token"], context["protocol"] + reset_password_uri = reverse_lazy( + "password_reset_check_and_confirm", kwargs={"uidb64": context["uid"], "token": context["token"]} ) + protocol = context["protocol"] + reset_password_url = f"{protocol}://{domain}{reset_password_uri}" - send_email( - NOTIFICATION_EMAIL, + send_dotdigital_email( + campaign_ids["reset_password"], [user.email], - email_subject_content["subject"], - email_subject_content["message"], - email_subject_content["subject"], + personalization_values={"RESET_PASSWORD_LINK": reset_password_url}, ) def _compute_protocol(self, use_https):