Create authorization system

This commit is contained in:
2026-01-05 23:31:36 +03:00
parent d438f7bf5b
commit 2e14a7f364
39 changed files with 2500 additions and 9 deletions
+33
View File
@@ -0,0 +1,33 @@
import logging
from app.utils.email_client import EmailClient
from app.config import settings
log = logging.getLogger(__name__)
class EmailService:
@classmethod
def send_verify_email(cls, email: str, username: str, url: str):
log.debug("Sending email to %s", email, extra={"email": email})
try:
subject = "Подтверждение эл. почты"
html = EmailClient.render(
template_path="confirm_email.html",
username=username,
url=url,
expire_minutes=60,
company_name=settings.COMPANY_NAME
)
body = EmailClient.render(
template_path="confirm_email.txt",
username=username,
url=url,
company_name=settings.COMPANY_NAME
)
EmailClient.send_email(to=email, subject=subject, html=html, body=body)
log.info("Verify email sent to %s", email, extra={"email": email})
except Exception as e:
log.error("Failed to send email to %s", email, extra={"email": email})
raise e