From b0a3b563e5c81b1afafbea68a41ac0b3050ce6f3 Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Thu, 14 Dec 2023 11:57:22 +0100 Subject: [PATCH] Auth: replace password reset task --- config/settings/base.py | 3 --- lemarche/www/auth/tasks.py | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/config/settings/base.py b/config/settings/base.py index 13f1bc90a..731733090 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -323,9 +323,6 @@ GIP_CONTACT_EMAIL = env("GIP_CONTACT_EMAIL", default="gip.contact@example.com") # Transactional email templates -# -- user: new user password reset -MAILJET_NEW_USER_PASSWORD_RESET_ID = env.int("MAILJET_NEW_USER_PASSWORD_RESET_ID", 4216730) - # -- siae: completion MAILJET_SIAE_COMPLETION_REMINDER_TEMPLATE_ID = env.int("MAILJET_SIAE_COMPLETION_REMINDER_TEMPLATE_ID", 4791779) diff --git a/lemarche/www/auth/tasks.py b/lemarche/www/auth/tasks.py index e8e7009ad..8ff2f92d8 100644 --- a/lemarche/www/auth/tasks.py +++ b/lemarche/www/auth/tasks.py @@ -5,6 +5,7 @@ from django.utils.encoding import force_bytes from django.utils.http import urlsafe_base64_encode +from lemarche.conversations.models import TemplateTransactional from lemarche.users import constants as user_constants from lemarche.users.models import User from lemarche.utils.apis import api_hubspot, api_mailjet @@ -43,7 +44,7 @@ def send_signup_notification_email(user): def send_new_user_password_reset_link(user: User): - email_subject = "Finalisez votre inscription sur le marché de l'inclusion" + email_template = TemplateTransactional.objects.get(code="NEW_USER_PASSWORD_RESET") recipient_list = whitelist_recipient_list([user.email]) if recipient_list: recipient_email = recipient_list[0] if recipient_list else "" @@ -51,12 +52,11 @@ def send_new_user_password_reset_link(user: User): variables = { "USER_FIRST_NAME": user.first_name, + "USER_EMAIL": user.email, "PASSWORD_RESET_LINK": generate_password_reset_link(user), } - api_mailjet.send_transactional_email_with_template( - template_id=settings.MAILJET_NEW_USER_PASSWORD_RESET_ID, - subject=email_subject, + email_template.send_transactional_email( recipient_email=recipient_email, recipient_name=recipient_name, variables=variables,