From e4286d9f04619030054b5a6425b059b783c6d87c Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 20 Aug 2024 17:05:27 -0500 Subject: Save to DB then send email Separate the saving of the token from its sending. --- gn_auth/auth/authorisation/users/views.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'gn_auth/auth/authorisation/users') diff --git a/gn_auth/auth/authorisation/users/views.py b/gn_auth/auth/authorisation/users/views.py index 839111e..ba74ab0 100644 --- a/gn_auth/auth/authorisation/users/views.py +++ b/gn_auth/auth/authorisation/users/views.py @@ -407,16 +407,17 @@ def send_forgot_password_email( timedelta( minutes=expiration_minutes)).timestamp()) }) - send_message(smtp_user=current_app.config["SMTP_USER"], - smtp_passwd=current_app.config["SMTP_PASSWORD"], - message=build_email_message( - from_address=current_app.config["EMAIL_ADDRESS"], - to_addresses=(user_address(user),), - subject=subject, - txtmessage=__render__("emails/forgot-password.txt"), - htmlmessage=__render__("emails/forgot-password.html")), - host=current_app.config["SMTP_HOST"], - port=current_app.config["SMTP_PORT"]) + + send_message(smtp_user=current_app.config["SMTP_USER"], + smtp_passwd=current_app.config["SMTP_PASSWORD"], + message=build_email_message( + from_address=current_app.config["EMAIL_ADDRESS"], + to_addresses=(user_address(user),), + subject=subject, + txtmessage=__render__("emails/forgot-password.txt"), + htmlmessage=__render__("emails/forgot-password.html")), + host=current_app.config["SMTP_HOST"], + port=current_app.config["SMTP_PORT"]) @users.route("/forgot-password", methods=["GET", "POST"]) -- cgit v1.2.3