Adds an optional cloud/paid mode behind a BILLING_ENABLED flag. With the flag off the app is byte-identical to today's self-hosted BYOK build (regression-zero). Backend (cloud/ package, only imported when BILLING_ENABLED): - Auth: magic link (Resend) + Google OAuth (authlib) + JWT sessions - Stripe: hosted Checkout with 3-day card trial, Customer Portal, idempotent order-safe webhooks; 3 plans (Starter/Creator/Pro) resolved by lookup_key - Postgres + SQLAlchemy async; atomic minute metering (reserve/commit/release, plan->topup FIFO, restart-safe) with sweeper - Managed keys: Gemini + Upload-Post server-side for entitled users; paid-only (BYOK core header ignored on hosted); Upload-Post white-label per-user profiles - Metering wired into /api/process (probe->reserve->402, priority queue) and thumbnail image generation (3 min/batch) - yt-dlp residential PROXY_URL support + 720p cap for hosted YouTube downloads Frontend: - AuthContext, LoginModal, PricingSection (3-day trial), AccountPage, UsageMeter, TopUpModal, TrialGate/AdvancedBanner - Paid-only UI: hide BYOK core inputs, trial prompts per tool - Included (Clip Generator, YouTube Studio) vs BYOK (AI Shorts/dubbing: fal.ai + ElevenLabs) clearly separated; ThumbnailStudio + SaaShortsTab managed-aware - Landing: free-self-host vs paid-hosted messaging Verified end-to-end against real Postgres + Stripe test mode.
36 lines
1.4 KiB
Python
36 lines
1.4 KiB
Python
"""Transactional email via Resend (magic-link login).
|
|
|
|
If RESEND_API_KEY is unset (e.g. local dev), the link is printed to the server
|
|
log instead of sent, so the login flow is still testable without a real inbox.
|
|
"""
|
|
import httpx
|
|
|
|
from .config import settings
|
|
|
|
|
|
async def send_magic_link_email(email: str, link: str):
|
|
if not settings.resend_api_key:
|
|
print(f"✉️ [DEV magic link] {email} -> {link}")
|
|
return
|
|
|
|
html = f"""
|
|
<div style="font-family:system-ui,sans-serif;max-width:480px;margin:0 auto">
|
|
<h2>Sign in to OpenShorts</h2>
|
|
<p>Click the button below to sign in. This link expires in 15 minutes.</p>
|
|
<p><a href="{link}" style="display:inline-block;background:#111;color:#fff;
|
|
padding:12px 20px;border-radius:8px;text-decoration:none">Sign in</a></p>
|
|
<p style="color:#666;font-size:13px">If you didn't request this, ignore this email.</p>
|
|
</div>
|
|
"""
|
|
async with httpx.AsyncClient(timeout=15) as client:
|
|
resp = await client.post(
|
|
"https://api.resend.com/emails",
|
|
headers={"Authorization": f"Bearer {settings.resend_api_key}"},
|
|
json={
|
|
"from": settings.email_from,
|
|
"to": [email],
|
|
"subject": "Your OpenShorts sign-in link",
|
|
"html": html,
|
|
},
|
|
)
|
|
resp.raise_for_status()
|