From cefcc6abb01abad6c12f690e3aa21fdea11c3a3e Mon Sep 17 00:00:00 2001 From: martbost Date: Sat, 1 Aug 2026 11:34:06 -0500 Subject: [PATCH] Cross-wire rescue: either username works in either param ?ref= now forward-resolves to the member's real ClickBaitPays ref (Marty hit this live with ref=r03430451480 -> now resolves opgnetwerk); ?ctb= reverse-resolves symmetrically. Wrong-slot links from confused members self-heal instead of leaking CTB usernames into CBP refs. Co-Authored-By: Claude Fable 5 --- index.html | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 61dbb4b..54513e4 100644 --- a/index.html +++ b/index.html @@ -2377,22 +2377,42 @@ async function resolveIdentity() { const p = new URLSearchParams(window.location.search); const ctbParam = (p.get('ctb') || '').trim(); try { + // Members mix the two usernames up constantly, so each param tries its + // own direction FIRST, then rescues by trying the other (a CTB username + // pasted into ?ref=, or a CBP username pasted into ?ctb=, both resolve). if (ctbParam) { const r = await fetch(`${CTB_LOOKUP_URL}?ctb=${encodeURIComponent(ctbParam)}`).then(x => x.json()); if (r.found) { IDENT.cbp = r.cbpUsername; IDENT.ctb = r.ctbUsername; } else { - // No ClickBaitPays entry in their downline builder: CBP signups fall - // back to the team account, but the hub link still aligns them in CTB. - IDENT.ctb = ctbParam; - IDENT.fallback = true; + const rv = await fetch(`${CTB_LOOKUP_URL}?cbp=${encodeURIComponent(ctbParam)}`).then(x => x.json()); + if (rv.found) { + IDENT.cbp = rv.cbpUsername; + IDENT.ctb = rv.ctbUsername; + } else { + // No ClickBaitPays entry in their downline builder: CBP signups fall + // back to the team account, but the hub link still aligns them in CTB. + IDENT.ctb = ctbParam; + IDENT.fallback = true; + } } } else { // Legacy/current ?ref= links (or the default): reverse-resolve the CTB // username so the Team Hub invite personalizes to the same sponsor. const r = await fetch(`${CTB_LOOKUP_URL}?cbp=${encodeURIComponent(IDENT.cbp)}`).then(x => x.json()); - if (r.found) IDENT.ctb = r.ctbUsername; + if (r.found) { + IDENT.ctb = r.ctbUsername; + } else { + // Rescue: the ?ref= value may actually BE a CTB username (Marty hit + // this live 2026-08-01 with ?ref=). Forward-resolve it + // and adopt the member's real ClickBaitPays ref for the signup links. + const f = await fetch(`${CTB_LOOKUP_URL}?ctb=${encodeURIComponent(IDENT.cbp)}`).then(x => x.json()); + if (f.found) { + IDENT.cbp = f.cbpUsername; + IDENT.ctb = f.ctbUsername; + } + } } } catch (e) { // Lookup unreachable: defaults stand, nothing breaks.