From 15f663a56d1d13d430c66e9902d6e341563826ec Mon Sep 17 00:00:00 2001 From: martbost Date: Tue, 29 Sep 2026 19:34:34 -0500 Subject: [PATCH] Invite link: GET shows a sign-in button, POST spends the token (link previews were consuming it) Co-Authored-By: Claude Fable 5.1 --- server.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index 4f14995..9622d61 100644 --- a/server.js +++ b/server.js @@ -895,9 +895,14 @@ const server = http.createServer(async (req, res) => { } if (p === '/api/zone/seen' && (req.method === 'GET' || req.method === 'POST')) { await zones.seen(u.searchParams.get('i'), req); res.writeHead(204, { 'Access-Control-Allow-Origin': '*' }); return res.end(); } { const zm = /^\/api\/zone\/click\/([a-f0-9]{12})$/.exec(p); if (zm && req.method === 'GET') { const target = await zones.click(zm[1]); res.writeHead(302, { Location: target || '/', 'Cache-Control': 'no-store', 'Referrer-Policy': 'no-referrer-when-downgrade' }); return res.end(); } } - { const wm = /^\/welcome\/([a-f0-9]{48})$/.exec(p); if (wm && req.method === 'GET') { // one-time tester sign-in link + { const wm = /^\/welcome\/([a-f0-9]{48})$/.exec(p); if (wm && (req.method === 'GET' || req.method === 'POST')) { // one-time tester sign-in link const t = inviteTokens.get(wm[1]); if (!t || t.exp < Date.now()) { inviteTokens.delete(wm[1]); res.writeHead(410, { 'Content-Type': 'text/html; charset=utf-8' }); return res.end('Link used

That sign-in link was already used or has expired. Ask for a fresh one.

'); } + // GET only shows a button: link-preview fetchers and in-app browsers prefetch links, and a prefetch must not spend the token + if (req.method === 'GET') { + res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'no-store', 'X-Robots-Tag': 'noindex' }); + return res.end('Sign in to LinkSpin
LINKSPIN TEST APP

Sign in as

' + esc(t.email) + '

One use. Good for 24 hours from when it was made.

'); + } inviteTokens.delete(wm[1]); const acct = await accounts.byEmail(t.email); let memberId = 0; if (acct && acct.address) { try { memberId = await chain.memberIdByAccount(acct.address); } catch (e) {} } const token = await auth.mintSession({ email: t.email, address: (acct && acct.address) || null, memberId });