PolHunter return loop: ?from=polhunter sets iap.return (landing + join links), /api/me carries returnTo, Overview card sends them back once a wallet is linked, wallet link answers next=/api/my/polhunter, hand-off clears the cookie

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-19 20:00:55 -05:00
parent ad539d5fae
commit 7ea7a5f409
3 changed files with 27 additions and 6 deletions
+16 -1
View File
@@ -1404,7 +1404,21 @@
}));
} catch (e) {}
}
// came from PolHunter (iap.return cookie): one card at the top of the Overview that sends them back
async function loadReturnCard() {
const card = $('phReturn'); if (!card) return;
try {
const me = await (await fetch('/api/me')).json();
if (me.returnTo !== 'polhunter') { card.hidden = true; return; }
card.hidden = false;
card.innerHTML = '<div class="card-head"><h3>You came from PolHunter</h3></div>' + (me.address
? '<p>Your wallet is linked, so your board is ready.</p><a class="btn" href="/api/my/polhunter">Back to PolHunter</a>'
: '<p>One step left: link the wallet your POL drips will be paid to. The moment it is linked you go straight back.</p><button class="btn" type="button" id="phGoWallet">Link my wallet</button>');
const b = $('phGoWallet'); if (b) b.addEventListener('click', () => { const m = document.querySelector('.bo-menu [data-pane="wallet"]'); if (m) m.click(); });
} catch (e) {}
}
async function loadCoach() {
loadReturnCard();
loadTank();
try {
const r = await (await fetch('/api/my/coach')).json();
@@ -2383,7 +2397,8 @@
}));
$('linkBtn').addEventListener('click', busy($('linkBtn'), async () => {
IAP.status('Check your wallet for the free link signature…');
await IAPWallet.signIn(); // server binds the wallet to the signed-in email account
const lr = await IAPWallet.signIn(); // server binds the wallet to the signed-in email account
if (lr && lr.next) { IAP.status('Wallet linked. Taking you back to PolHunter…', 'ok'); setTimeout(() => { location.href = lr.next; }, 700); return; } // they came from PolHunter: close the loop
IAP.status('Wallet linked. Earnings pay there from now on.', 'ok');
await render();
}));
+2 -1
View File
@@ -172,6 +172,7 @@
<main class="bo-content">
<div class="pane" id="pane-overview">
<div class="card" id="phReturn" hidden></div>
<div class="card gs" id="gsCard" hidden>
<div class="card-head"><h3>Getting started</h3><span class="sub" id="gsSub"></span></div>
<div class="gs-steps" id="gsSteps"></div>
@@ -1037,7 +1038,7 @@
<script src="/assets/common.js?v=20260916a"></script>
<script src="/assets/wallet.js?v=20260911a"></script>
<script src="/assets/promo.js?v=20260911a"></script>
<script src="/assets/my.js?v=20260919b"></script>
<script src="/assets/my.js?v=20260920b"></script>
<script src="/assets/chat.js?v=20260907l"></script>
</body>
</html>