From d215c025b028ed3e0d5d7797af14f31475aeafa8 Mon Sep 17 00:00:00 2001 From: martbost Date: Thu, 8 Oct 2026 06:47:06 -0500 Subject: [PATCH] /api/me sponsor fallback also capped at the on-chain member count (the Credits screen activates from /api/me) Co-Authored-By: Claude Fable 5.1 --- server.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server.js b/server.js index db053fb..a6e0ad5 100644 --- a/server.js +++ b/server.js @@ -1330,6 +1330,7 @@ const server = http.createServer(async (req, res) => { if (sponsorId && await payoutChainBlocked(sponsorId, 2)) sponsorId = 0; const _defSpon = Number(siteConfig().defaultSponsorId) || 1; if (!sponsorId && memberId !== _defSpon) sponsorId = _defSpon; // orphan fallback → #1 (never self-sponsor) + if (sponsorId) { try { if (sponsorId > await chain.memberCount()) sponsorId = 0; } catch (e) {} } // fresh contract: no catch position exists yet, the first member becomes #1 if (memberId && acct && acct.memberId !== memberId) accounts.setMemberId(acct.email, memberId).catch(() => {}); const out = { signedIn: true, sponsorBlocked, sponsorName: spdMe.name || null, email: s.email || (acct && acct.email) || null, address: s.address || (acct && acct.address) || null, memberId,