Earners Corner invites credit the inviter (Marty 2026-11-10): /forum/join/<username>[?to=/path] sets the member as sponsor exactly like /join/ (30-day cookie, last touch wins, first-touch source earnerscorner.com, link view recorded) and forwards to the forum (?to= must be an on-forum path); /forum/invite shows a signed-in member their link. The forum's Log In carries a shared thread's ?u= through this route. qa/forumsso 14/14 (incl. a new sign-up landing under the inviter); member walk 0 bugs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-10 08:29:00 -06:00
parent ef28c16502
commit e00c820d2f
2 changed files with 47 additions and 0 deletions
+34
View File
@@ -3935,6 +3935,40 @@ const server = http.createServer(async (req, res) => {
}
// -- Earners Corner forum sign-in (2026-11-10): Discourse sends /forum/sso; a signed-out visitor signs in on /my first (the request
// rides in a 30-minute cookie) and /api/my/forum finishes the hand-back. See forumsso.js.
// -- Earners Corner invite + shared-thread credit (Marty 2026-11-10): /forum/join/<username>[?to=/path] sets the member as sponsor
// exactly like /join/<username> (30-day cookie, last touch wins, first-touch source recorded), then forwards to the forum. A
// visitor who later signs in on the forum creates their InstantAdPay account here, so the sponsor cookie is already in place.
// /forum/invite shows a signed-in member their own forum invite link.
m = /^\/forum\/join\/([A-Za-z0-9_]{1,20})$/.exec(p);
if (m && (req.method === 'GET' || req.method === 'HEAD')) {
const to = String(u.searchParams.get('to') || '/'); const path = /^\/(?!\/)[\w\-./?=&%]*$/.test(to) ? to : '/';
const a = await accounts.byUsername(m[1].toLowerCase());
const set = [];
if (a && a.username && !fraud.isSuspended(a.email)) {
const cookieTail = `; Path=/; SameSite=Lax; Max-Age=${30 * 24 * 3600}${IS_PROD ? '; Secure' : ''}`;
set.push('iap.sponsor=' + a.username + cookieTail); // last touch wins, same as /join/
if (!parseCookies(req)['iap.ref']) set.push('iap.ref=' + encodeURIComponent('earnerscorner.com') + cookieTail);
if (req.method === 'GET') coach.recordView(a.username, '', 'https://earnerscorner.com/');
}
res.writeHead(302, baseHeaders(Object.assign({ Location: forumsso.FORUM_URL() + path, 'Cache-Control': 'no-store' }, set.length ? { 'Set-Cookie': set } : {}))); return res.end();
}
if (p === '/forum/invite' && req.method === 'GET') {
const s = await auth.fromRequest(req);
if (!s || !s.email) { res.writeHead(302, { Location: forumsso.FORUM_URL() + '/session/sso', 'Cache-Control': 'no-store' }); return res.end(); }
const a = await accounts.byEmail(s.email); const un = a && a.username;
const link = un ? 'https://instantadpay.com/forum/join/' + un : '';
const esc = x => String(x).replace(/[&<>"]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
const body = '<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Your Earners Corner invite link</title>'
+ '<style>body{margin:0;font:16px/1.55 system-ui,-apple-system,Segoe UI,sans-serif;background:#13101f;color:#efeafb;display:grid;place-items:center;min-height:100vh;padding:16px}'
+ '.c{max-width:560px;width:100%;background:#1c1830;border:1px solid #2f2947;border-radius:16px;padding:24px}h1{font-size:22px;margin:0 0 6px}p{color:#bdb5d6;margin:0 0 14px}'
+ 'input{width:100%;box-sizing:border-box;font:600 15px ui-monospace,Consolas,monospace;padding:12px;border-radius:10px;border:1px solid #6d28d9;background:#0f0c1a;color:#fff}'
+ 'a{color:#f5b74a}.s{font-size:13px;margin-top:14px}</style></head><body><div class="c"><h1>Your Earners Corner invite link</h1>'
+ (un ? '<p>Share this link. Anyone who joins the forum through it, or through a thread you share while signed in, signs up with you as their sponsor, exactly like your InstantAdPay referral link.</p>'
+ '<input readonly value="' + esc(link) + '" aria-label="Your invite link"><p class="s">Tap the box, select all and copy. To share one thread, use the share button under any post while you are signed in to the forum: those links carry your name too.</p>'
: '<p>Pick a username in your InstantAdPay profile first, then come back here for your invite link.</p><p><a href="/my#profile">Open your profile</a></p>')
+ '<p class="s"><a href="' + esc(forumsso.FORUM_URL()) + '/">Back to Earners Corner</a></p></div></body></html>';
res.writeHead(200, baseHeaders({ 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'no-store' })); return res.end(body);
}
if ((p === '/forum/sso' || p === '/api/my/forum') && req.method === 'GET') {
const raw = p === '/forum/sso' ? { sso: u.searchParams.get('sso'), sig: u.searchParams.get('sig') } : (() => { const c = String(parseCookies(req)['iap.forumsso'] || ''); const i = c.lastIndexOf('.'); return { sso: c.slice(0, i), sig: c.slice(i + 1) }; })();
const v = forumsso.verify(raw.sso, raw.sig);