Last active
October 5, 2022 12:13
-
-
Save gajanan0707/8abefdfdcb2921b5fa8bbbdf70b6c068 to your computer and use it in GitHub Desktop.
FlASK_DEMO_REST/users/helper.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from flask_mail import Message | |
from utils.common import TokenGenerator | |
from server import mail | |
def send_forgot_password_email(request, user): | |
""" | |
It sends an email to the user with a link to reset their password | |
:param request: The request object | |
:param user: The user object of the user who requested the password reset | |
""" | |
current_site = request.url_root | |
mail_subject = "Reset your password" | |
domain = os.environ.get("API_URL") | |
uid = user.id | |
token = TokenGenerator.encode_token(user) | |
msg = Message( | |
mail_subject, sender=os.environ.get("EMAIL_HOST_USER"), recipients=[user.email] | |
) | |
msg.html = f"Please click on the link to reset your password, {domain}/pages/auth/reset-password/{uid}/{token}" | |
mail.send(msg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment