This commit is contained in:
2026-04-01 18:31:33 +02:00
parent 6e23e32bb0
commit b5c7c5305a
95 changed files with 9609 additions and 2374 deletions

View File

@@ -0,0 +1,54 @@
import os
import resend
from core.config import RESEND_API_KEY, EMAIL_FROM, FRONTEND_URL
def send_verification_email(to_email: str, username: str, token: str):
resend.api_key = RESEND_API_KEY
verify_url = f"{FRONTEND_URL}/verify-email?token={token}"
resend.Emails.send({
"from": EMAIL_FROM,
"to": to_email,
"subject": "Verify your WikiTCG email",
"html": f"""
<div style="font-family: serif; max-width: 480px; margin: 0 auto; color: #1a1208;">
<h2 style="color: #b87830;">Welcome to WikiTCG</h2>
<p>Hi {username},</p>
<p>Please verify your email address to complete your registration:</p>
<p style="margin: 2rem 0;">
<a href="{verify_url}" style="background: #c8861a; color: #fff8e0; padding: 10px 24px; border-radius: 6px; text-decoration: none; font-family: sans-serif; font-size: 14px;">
Verify Email
</a>
</p>
<p>This link expires in 24 hours.</p>
<p style="color: #888; font-size: 13px;">- WikiTCG</p>
</div>
""",
})
def send_password_reset_email(to_email: str, username: str, reset_token: str):
resend.api_key = RESEND_API_KEY
reset_url = f"{FRONTEND_URL}/forgot-password/reset?token={reset_token}"
resend.Emails.send({
"from": EMAIL_FROM,
"to": to_email,
"subject": "Reset your WikiTCG password",
"html": f"""
<div style="font-family: serif; max-width: 480px; margin: 0 auto; color: #1a1208;">
<h2 style="color: #b87830;">WikiTCG Password Reset</h2>
<p>Hi {username},</p>
<p>Someone requested a password reset for your account. If this was you, click the link below:</p>
<p style="margin: 2rem 0;">
<a href="{reset_url}" style="background: #c8861a; color: #fff8e0; padding: 10px 24px; border-radius: 6px; text-decoration: none; font-family: sans-serif; font-size: 14px;">
Reset Password
</a>
</p>
<p>This link expires in 1 hour. If you didn't request this, you can safely ignore this email.</p>
<p style="color: #888; font-size: 13px;">- WikiTCG</p>
</div>
""",
})