2021-05-29 18:22:51 +02:00
|
|
|
# -*- coding: UTF-8 -*
|
2023-03-14 16:30:27 +01:00
|
|
|
|
|
|
|
from flask import render_template
|
|
|
|
from app.auth.models import User
|
2023-02-28 19:43:48 +01:00
|
|
|
from app.email import get_from_addr, send_email
|
2021-05-29 18:22:51 +02:00
|
|
|
|
|
|
|
|
2023-03-14 16:30:27 +01:00
|
|
|
def send_password_reset_email(user: User):
|
|
|
|
"""Send message allowing to reset password"""
|
|
|
|
recipients = user.get_emails()
|
|
|
|
if not recipients:
|
|
|
|
return
|
2021-05-29 18:22:51 +02:00
|
|
|
token = user.get_reset_password_token()
|
|
|
|
send_email(
|
2021-08-28 16:01:41 +02:00
|
|
|
"[ScoDoc] Réinitialisation de votre mot de passe",
|
2023-02-28 19:43:48 +01:00
|
|
|
sender=get_from_addr(),
|
2023-03-14 16:30:27 +01:00
|
|
|
recipients=recipients,
|
2021-05-29 18:22:51 +02:00
|
|
|
text_body=render_template("email/reset_password.txt", user=user, token=token),
|
2023-01-30 22:25:17 +01:00
|
|
|
html_body=render_template("email/reset_password.j2", user=user, token=token),
|
2021-05-29 18:22:51 +02:00
|
|
|
)
|