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:
+16
-1
@@ -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();
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user