fix wrangler + send magic link

This commit is contained in:
Arthur Belleville 2026-04-15 17:13:23 +02:00
parent 34e112efa7
commit abc0e65a86
No known key found for this signature in database
5 changed files with 23 additions and 8 deletions

View file

@ -56,7 +56,7 @@ const createClientInvite = (middlewareManager: ReturnType<typeof MiddlewareManag
const clientsUrl = process.env.CLIENTS_URL || "https://clients.xtablo.com";
const redirectTo = `${clientsUrl}/auth/callback?token=${encodeURIComponent(token)}`;
const { error: magicLinkError } = await supabase.auth.admin.generateLink({
const { data: linkData, error: magicLinkError } = await supabase.auth.admin.generateLink({
type: "magiclink",
email: rawEmail,
options: { redirectTo },
@ -65,6 +65,24 @@ const createClientInvite = (middlewareManager: ReturnType<typeof MiddlewareManag
if (magicLinkError) {
console.error("Failed to generate magic link:", magicLinkError);
// Non-fatal: invite record is already created
} else if (linkData?.properties?.action_link) {
const transporter = c.get("transporter");
try {
await transporter.sendMail({
from: "Xtablo <noreply@xtablo.com>",
to: rawEmail,
subject: "Vous avez été invité sur Xtablo",
html: `
<h2>Vous avez é invité à collaborer sur un tablo</h2>
<p>Bonjour,</p>
<p>Cliquez sur le lien ci-dessous pour accéder à votre espace client :</p>
<p><a href="${linkData.properties.action_link}">Accéder à mon espace</a></p>
<p>Ce lien expire dans ${CLIENT_INVITE_EXPIRY_HOURS} heures.</p>
`,
});
} catch (emailError) {
console.error("Failed to send client invite email:", emailError);
}
}
return c.json({ success: true });

View file

@ -8,7 +8,7 @@
"build": "tsc -b && vite build --mode production",
"build:staging": "tsc -b && vite build --mode staging",
"build:prod": "tsc -b && vite build --mode production",
"deploy": "wrangler deploy",
"deploy:prod": "wrangler deploy --env=\"\"",
"typecheck": "tsc -b",
"lint": "biome check .",
"lint:fix": "biome check --write .",

View file

@ -0,0 +1 @@
{"root":["./src/app.tsx","./src/i18n.ts","./src/main.tsx","./src/routes.tsx","./src/components/clientlayout.tsx","./src/lib/supabase.ts","./src/pages/authcallback.tsx","./src/pages/clienttablolistpage.tsx","./src/pages/clienttablopage.tsx"],"version":"5.9.3"}

View file

@ -1,6 +1,7 @@
name = "xtablo-clients"
main = "worker/index.ts"
compatibility_date = "2025-07-09"
route = { pattern = "clients.xtablo.com", custom_domain = true }
[assets]
directory = "./dist/"
@ -8,9 +9,3 @@ not_found_handling = "single-page-application"
[observability]
enabled = true
[env.staging]
route = { pattern = "clients-staging.xtablo.com", custom_domain = true }
[env.production]
route = { pattern = "clients.xtablo.com", custom_domain = true }

View file

@ -21,6 +21,7 @@
"deploy:main:prod": "turbo deploy:prod --filter=@xtablo/main",
"deploy:chat": "turbo deploy --filter=@xtablo/chat-worker",
"deploy:external": "turbo deploy --filter=@xtablo/external",
"deploy:clients": "turbo deploy:prod --filter=@xtablo/clients",
"lint": "turbo lint",
"lint:fix": "turbo lint:fix",
"format": "turbo format",