From 6e6d15fec18c052fb5f01344fce27bf8934828e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89loi=20Rivard?= Date: Fri, 5 May 2023 10:53:48 +0200 Subject: [PATCH] Fixed password initialization mail recipients --- CHANGES.rst | 1 + canaille/core/account.py | 4 ++-- tests/core/test_profile_settings.py | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index a8992f08..fb3b346c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -21,6 +21,7 @@ Fixed - ``OIDC.JWT.MAPPING`` configuration entry is really optional now. - Fixed empty model attributes registration :pr:`125` +- Password initialization mails were not correctly sent. :pr:`128` [0.0.24] - 2023-04-07 ===================== diff --git a/canaille/core/account.py b/canaille/core/account.py index b8aef53b..8514744c 100644 --- a/canaille/core/account.py +++ b/canaille/core/account.py @@ -527,7 +527,7 @@ def profile_settings(user, username): return profile_delete(user, edited_user) if request.form.get("action") == "password-initialization-mail": - if send_password_initialization_mail(user): + if send_password_initialization_mail(edited_user): flash( _( "A password initialization link has been sent at the user email address. It should be received within a few minutes." @@ -540,7 +540,7 @@ def profile_settings(user, username): return profile_settings_edit(user, edited_user) if request.form.get("action") == "password-reset-mail": - if send_password_reset_mail(user): + if send_password_reset_mail(edited_user): flash( _( "A password reset link has been sent at the user email address. It should be received within a few minutes." diff --git a/tests/core/test_profile_settings.py b/tests/core/test_profile_settings.py index 8e461974..a53fad88 100644 --- a/tests/core/test_profile_settings.py +++ b/tests/core/test_profile_settings.py @@ -145,6 +145,7 @@ def test_password_initialization_mail( "It should be received within a few minutes.", ) in res.flashes assert len(smtpd.messages) == 1 + assert smtpd.messages[0]["X-RcptTo"] == "john@doe.com" u.reload() u.password = ["correct horse battery staple"] @@ -253,6 +254,7 @@ def test_password_reset_email(smtpd, testclient, slapd_connection, logged_admin) "It should be received within a few minutes.", ) in res.flashes assert len(smtpd.messages) == 1 + assert smtpd.messages[0]["X-RcptTo"] == "john@doe.com" u.delete()