diff --git a/server/routers/authentication.py b/server/routers/authentication.py index e612e57..c1473bd 100644 --- a/server/routers/authentication.py +++ b/server/routers/authentication.py @@ -1,5 +1,6 @@ import os import html +from pathlib import Path from dotenv import load_dotenv from datetime import datetime, timedelta, timezone, UTC, date from secrets import token_urlsafe @@ -27,6 +28,7 @@ from ..utils.email_service import send_email from ..utils.audit_log import write_audit_log + EMAIL_VALIDATION_ENABLED = True ALGORITHM = 'HS256' ACCESS_TOKEN_EXPIRE_MINUTES = 30 @@ -207,7 +209,7 @@ def _send_validation_email(user: UserAccount, token: str): validation_url = f"{BACKEND_URL}/validate-email?token={token}" - logo_url = f"{BACKEND_URL}/static/images/wellai-logo.png" + logo_path = Path(__file__).resolve().parent.parent / "static" / "images" / "wellai-logo.png" email_subject = "Verify your WellAI account" @@ -236,7 +238,7 @@ def _send_validation_email(user: UserAccount, token: str): border-bottom: 1px solid #eeeeee; "> WellAI" + ) + image.add_header( + "Content-Disposition", + "inline", + filename=image_path.name + ) + + message.attach(image) + + else: + # Keep the existing behavior for normal emails. + message = MIMEMultipart("alternative") + + if content_type.lower() == "html": + message.attach(MIMEText(content, "html")) + else: + message.attach(MIMEText(content, "plain")) + message["Subject"] = subject message["From"] = f"{sender_name} <{sender_email}>" message["To"] = recipient - if content_type.lower() == "html": - message.attach(MIMEText(content, "html")) - else: - message.attach(MIMEText(content, "plain")) - print("===== BREVO EMAIL =====") print(f"Sending email to: {recipient}") print(f"Subject: {subject}")