Skip to content

Commit cf5d526

Browse files
ralyodioclaude
andcommitted
Show CoinPay connection status on homepage
Checks /api/oauth/coinpay/session on load and updates the Connect button to reflect the authenticated user's email when already connected. Also cleans the coinpay_oauth query param from the URL after OAuth callback. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 4682b26 commit cf5d526

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

apps/logicsrc-web/src/main.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,3 +498,40 @@ const pageRoute = window.location.pathname.slice(1);
498498
if (["docs", "blog", "openspec", "credential-sharing", "hire-us", "about", "terms", "privacy"].includes(pageRoute)) {
499499
document.querySelector(`#${pageRoute}`)?.scrollIntoView();
500500
}
501+
502+
// CoinPay OAuth connection status
503+
const coinpayParam = new URLSearchParams(window.location.search).get("coinpay_oauth");
504+
if (coinpayParam) {
505+
const url = new URL(window.location.href);
506+
url.searchParams.delete("coinpay_oauth");
507+
url.searchParams.delete("error");
508+
history.replaceState(null, "", url.pathname + (url.search || ""));
509+
}
510+
511+
async function updateCoinPayButton() {
512+
const connectBtn = document.querySelector<HTMLAnchorElement>(".hero-actions a[href='/api/oauth/coinpay/start']");
513+
if (!connectBtn) return;
514+
515+
try {
516+
const res = await fetch("/api/oauth/coinpay/session");
517+
const data = await res.json();
518+
519+
if (data.authenticated && data.user) {
520+
const label = data.user.email || data.user.name || data.user.sub || "CoinPay";
521+
connectBtn.textContent = `Connected: ${label}`;
522+
connectBtn.style.background = "#3a9e7e";
523+
connectBtn.removeAttribute("href");
524+
connectBtn.style.cursor = "default";
525+
connectBtn.title = `Connected via CoinPay since ${new Date(data.user.connected_at).toLocaleDateString()}`;
526+
} else if (coinpayParam === "connected") {
527+
connectBtn.textContent = "CoinPay Connected";
528+
connectBtn.style.background = "#3a9e7e";
529+
} else if (coinpayParam === "error") {
530+
connectBtn.textContent = "Connect CoinPay (retry)";
531+
}
532+
} catch {
533+
// session check failed — leave button as-is
534+
}
535+
}
536+
537+
updateCoinPayButton();

0 commit comments

Comments
 (0)