Skip to content

Commit

Permalink
fix: move reset password email
Browse files Browse the repository at this point in the history
  • Loading branch information
evemartin committed Apr 10, 2024
1 parent dac0b40 commit 3e472f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions cfl_common/common/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 10 additions & 7 deletions portal/forms/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 3e472f3

Please sign in to comment.