diff --git a/src/auth/mailer.py b/src/auth/mailer.py index 845bd64..f94982e 100644 --- a/src/auth/mailer.py +++ b/src/auth/mailer.py @@ -63,3 +63,8 @@ def send_verification_email(email: str, token: str) -> None: def send_reset_email(email: str, token: str) -> None: link = f"{_base_url()}/reinitialiser-mot-de-passe?token={token}" _send_template(_template_id("BREVO_TEMPLATE_RESET_ID"), email, {"link": link}) + + +def send_email_change_email(email: str, token: str) -> None: + link = f"{_base_url()}/auth/confirm-email-change?token={token}" + _send_template(_template_id("BREVO_TEMPLATE_VERIFY_ID"), email, {"link": link}) diff --git a/tests/auth/test_mailer.py b/tests/auth/test_mailer.py index 8afd727..fa070c2 100644 --- a/tests/auth/test_mailer.py +++ b/tests/auth/test_mailer.py @@ -61,3 +61,14 @@ def test_send_without_init_raises(monkeypatch): monkeypatch.setenv("BREVO_TEMPLATE_VERIFY_ID", "11") with pytest.raises(AssertionError): mailer.send_verification_email("a@b.c", "TOKEN123") + + +def test_send_email_change_email(fake_client): + mailer.send_email_change_email("new@example.fr", "tok123") + + calls = fake_client.transactional_emails.calls + assert len(calls) == 1 + call = calls[0] + assert call["template_id"] == 11 + assert call["to"][0].email == "new@example.fr" + assert "/auth/confirm-email-change?token=tok123" in call["params"]["link"]