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
+13
View File
@@ -53,6 +53,19 @@ try {
ok(pl.get('nonce') === 'abc123' && pl.get('email') === 'fs-a@example.com' && pl.get('external_id') === 'fs-a@example.com' && pl.get('username') === 'forumfan', 'payload: nonce, email, external id, username', pl.toString().slice(0, 200));
ok(pl.get('website') === 'https://stackpol.com/forumfan' && (pl.get('remove_groups') || '').includes('network_members'), 'free member: no network_members group, profile links their Stack POL page');
r = await get('/forum/sso?sso=' + encodeURIComponent(sso) + '&sig=' + sig(sso), { Cookie: h.Cookie }); ok(r.status === 302 && (r.headers.get('location') || '').startsWith('https://earnerscorner.com/session/sso_login?sso='), 'already signed in -> straight back');
// invite link + shared-thread credit (2026-11-10)
r = await get('/forum/join/forumfan?to=' + encodeURIComponent('/t/some-thread/23?u=forumfan'));
const ick = (r.headers.getSetCookie ? r.headers.getSetCookie() : []).map(c => c.split(';')[0]);
ok(r.status === 302 && r.headers.get('location') === 'https://earnerscorner.com/t/some-thread/23?u=forumfan' && ick.includes('iap.sponsor=forumfan'), 'invite link sets the member as sponsor and forwards to the thread', JSON.stringify(ick));
r = await get('/forum/join/nosuchperson'); ok(r.status === 302 && !(r.headers.getSetCookie ? r.headers.getSetCookie() : []).some(c => c.startsWith('iap.sponsor=')), 'unknown username: forwards, sets no sponsor');
r = await get('/forum/join/forumfan?to=' + encodeURIComponent('//evil.example/x')); ok(r.headers.get('location') === 'https://earnerscorner.com/', 'off-site ?to= is refused');
const inv = await fetch(B + '/forum/invite', { headers: { Cookie: h.Cookie } }); const ih = await inv.text();
ok(inv.status === 200 && ih.includes('https://instantadpay.com/forum/join/forumfan'), 'invite page shows the member their link');
const nb = await fetch(B + '/api/auth/email/start', { method: 'POST', headers: { 'Content-Type': 'application/json', Cookie: 'iap.sponsor=forumfan' }, body: JSON.stringify({ email: 'fs-new@example.com', fts: Date.now() - 5000 }) }); const nbj = await nb.json();
const nv = await fetch(B + '/api/auth/email/verify', { method: 'POST', headers: { 'Content-Type': 'application/json', Cookie: 'iap.sponsor=forumfan' }, body: JSON.stringify({ email: 'fs-new@example.com', code: nbj.devCode }) });
const nck = (nv.headers.getSetCookie ? nv.headers.getSetCookie() : []).map(c => c.split(';')[0]).join('; ');
const nme = await api('/api/me', null, { Cookie: nck + '; iap.sponsor=forumfan' });
ok(nme.j && (nme.j.sponsorName === '@forumfan' || String(nme.j.sponsorRef || '').toLowerCase() === 'forumfan' || JSON.stringify(nme.j).includes('forumfan')), 'a new sign-up through the forum invite lands under the inviter', JSON.stringify(nme.j && { sponsorName: nme.j.sponsorName, sponsorRef: nme.j.sponsorRef }));
} catch (e) { console.log('FAIL exception', e && e.stack || e); fails++; }
finally { try { srv.kill(); } catch (e) {} try { fs.rmSync(DATA, { recursive: true, force: true }); } catch (e) {} }
if (fails) console.log(log.split('\n').filter(l => /forum|error/i.test(l)).slice(-15).join('\n'));