Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
refactor(cloudcp): unify Pulse Account app shell
rcourtman89b67fbb396b
diff --git a/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md b/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.mdindex 18953eca74..9efbf05377 100644--- a/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md+++ b/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md@@ -1,6 +1,6 @@# Pulse Account Portal Spec-Last updated: 2026-03-25+Last updated: 2026-03-26Status: ACTIVE## Purpose@@ -227,14 +227,19 @@ The `customer-account-portal` lane should deliver:### Current frontend seam-The current `/portal` shell now emits a machine-owned bootstrap payload in a-`pulse-account-bootstrap` JSON script tag. That payload is the canonical-frontend state seam for:+The current `/portal` surface now renders one machine-owned application shell+for both signed-out and signed-in users. That shell emits a+`pulse-account-bootstrap` JSON script tag, and the authenticated runtime can+refresh from `/api/portal/bootstrap`. Together, those two surfaces are the+canonical frontend state seam for:1. account identity context2. hosted account and workspace summaries3. public/commercial edge URLs needed by the account shell-4. the canonical bootstrap route path and stable workspace summary fields, so+4. signed-out versus signed-in shell state, so login, session expiry, and+ authenticated account runtime all inherit one owned page contract instead of+ separate server-rendered templates+5. the canonical bootstrap route path and stable workspace summary fields, sothe frontend can render and refresh account/workspace state from one ownedcontract instead of depending on server-rendered DOM structurediff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 0eec99e87b..5672a5e898 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -193,12 +193,15 @@ The Pulse Account commercial shell now also owns a dedicated bootstrapcontract in `internal/cloudcp/portal/page.go`, `internal/cloudcp/portal/handlers.go`,and `internal/cloudcp/portal/handlers_test.go`. `/api/portal/bootstrap` andthe in-page `pulse-account-bootstrap` payload must stay shape-identical for-account identity context, workspace summaries, and renderer-owned public,-commercial, and control-plane route configuration, including the canonical-bootstrap route path and stable workspace summary fields such as `created_at`.-New account frontend work must extend that shared contract rather than-inventing a second local payload shape or hardcoding production URLs, route-prefixes, or DOM-scraped account facts in static assets.+account identity context, signed-out versus signed-in shell state, workspace+summaries, and renderer-owned public, commercial, and control-plane route+configuration, including the canonical bootstrap route path, magic-link request+path, signup path, and stable workspace summary fields such as `created_at`.+`/portal` is now one bootstrap-driven shell for both anonymous and+authenticated users, so new account frontend work must extend that shared+contract rather than inventing a second local payload shape, reviving separate+login/portal templates, or hardcoding production URLs, route prefixes, or+DOM-scraped account facts in static assets.Hosted Pulse Cloud tenant-org AI reads now also follow that same canonicalrule: `internal/api/ai_hosted_runtime.go`, `internal/api/ai_handlers.go`,`internal/api/ai_handler.go`, and `internal/api/hosted_billing_state.go`diff --git a/internal/cloudcp/portal/assets/login.css b/internal/cloudcp/portal/assets/login.cssdeleted file mode 100644index 875b2ff1f0..0000000000--- a/internal/cloudcp/portal/assets/login.css+++ /dev/null@@ -1,15 +0,0 @@- :root { color-scheme: light; }- body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: linear-gradient(140deg, #f8fafc, #e2e8f0); color: #0f172a; display: flex; align-items: center; justify-content: center; min-height: 100vh; }- .card { background: #fff; border-radius: 12px; border: 1px solid #e2e8f0; box-shadow: 0 8px 30px rgba(15,23,42,.08); padding: 32px 28px; width: 100%; max-width: 400px; margin: 16px; }- .brand { font-size: 22px; font-weight: 700; margin-bottom: 6px; }- .subtitle { color: #64748b; font-size: 14px; margin-bottom: 24px; }- label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }- input { width: 100%; border: 1px solid #cbd5e1; border-radius: 8px; padding: 10px 12px; font-size: 15px; }- input:focus { outline: 2px solid #1d4ed8; border-color: transparent; }- .cta { margin-top: 14px; border: 0; border-radius: 10px; background: #1d4ed8; color: #fff; font-size: 15px; font-weight: 600; padding: 11px 16px; width: 100%; cursor: pointer; }- .cta:hover { background: #1e40af; }- .cta:disabled { opacity: 0.6; cursor: default; }- .success { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; padding: 14px; color: #166534; font-size: 14px; line-height: 1.5; display: none; margin-top: 14px; }- .error { background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px; padding: 12px; color: #991b1b; font-size: 14px; display: none; margin-top: 14px; }- .footer { margin-top: 20px; text-align: center; font-size: 12px; color: #94a3b8; }- .footer a { color: #1d4ed8; text-decoration: none; }diff --git a/internal/cloudcp/portal/assets/login.js b/internal/cloudcp/portal/assets/login.jsdeleted file mode 100644index 42ab411005..0000000000--- a/internal/cloudcp/portal/assets/login.js+++ /dev/null@@ -1,52 +0,0 @@-var emailEl = document.getElementById('email');-var sendBtn = document.getElementById('send-btn');-var successEl = document.getElementById('success');-var errEl = document.getElementById('err-msg');--async function sendMagicLink() {- var email = emailEl.value.trim();- if (!email) { emailEl.focus(); return; }- sendBtn.disabled = true;- sendBtn.textContent = 'Sending…';- errEl.style.display = 'none';- try {- var r = await fetch('/api/public/magic-link/request', {- method: 'POST',- headers: { 'Content-Type': 'application/json' },- body: JSON.stringify({ email: email })- });- if (r.ok || r.status === 404) {- successEl.style.display = 'block';- sendBtn.style.display = 'none';- emailEl.style.display = 'none';- document.querySelector('label').style.display = 'none';- } else if (r.status === 429) {- errEl.textContent = 'Too many requests. Please wait a moment and try again.';- errEl.style.display = 'block';- sendBtn.disabled = false;- sendBtn.textContent = 'Send magic link';- } else {- errEl.textContent = 'Something went wrong. Please try again.';- errEl.style.display = 'block';- sendBtn.disabled = false;- sendBtn.textContent = 'Send magic link';- }- } catch (_) {- errEl.textContent = 'Network error. Please check your connection and try again.';- errEl.style.display = 'block';- sendBtn.disabled = false;- sendBtn.textContent = 'Send magic link';- }-}--sendBtn.onclick = sendMagicLink;-emailEl.addEventListener('keydown', function(e) { if (e.key === 'Enter') sendMagicLink(); });-document.getElementById('resend-link').onclick = function(e) {- e.preventDefault();- successEl.style.display = 'none';- sendBtn.style.display = '';- emailEl.style.display = '';- document.querySelector('label').style.display = '';- sendBtn.disabled = false;- sendBtn.textContent = 'Send magic link';-};diff --git a/internal/cloudcp/portal/assets/portal_services.js b/internal/cloudcp/portal/assets/portal_services.jsindex bd6f981e86..ee38c0eeca 100644--- a/internal/cloudcp/portal/assets/portal_services.js+++ b/internal/cloudcp/portal/assets/portal_services.js@@ -598,14 +598,26 @@}}- renderOpenPanels();- var bootstrap = runtime.getBootstrap ? (runtime.getBootstrap() || {}) : {};- serviceState.flows.manage.emailValue = bootstrap.email || '';- serviceState.flows.retrieve.emailValue = bootstrap.email || '';- serviceState.flows.export.emailValue = bootstrap.email || '';- serviceState.flows.delete.emailValue = bootstrap.email || '';- serviceState.refund.emailValue = bootstrap.email || '';- renderAllFlows();+ function syncServiceStateFromBootstrap() {+ var bootstrap = runtime.getBootstrap ? (runtime.getBootstrap() || {}) : {};+ if (!bootstrap.authenticated) {+ return;+ }+ if (!serviceState.flows.manage.emailValue) serviceState.flows.manage.emailValue = bootstrap.email || '';+ if (!serviceState.flows.retrieve.emailValue) serviceState.flows.retrieve.emailValue = bootstrap.email || '';+ if (!serviceState.flows.export.emailValue) serviceState.flows.export.emailValue = bootstrap.email || '';+ if (!serviceState.flows.delete.emailValue) serviceState.flows.delete.emailValue = bootstrap.email || '';+ if (!serviceState.refund.emailValue) serviceState.refund.emailValue = bootstrap.email || '';+ }++ function renderServiceRuntime() {+ syncServiceStateFromBootstrap();+ renderOpenPanels();+ renderAllFlows();+ }++ renderServiceRuntime();+ document.addEventListener('pulse-account-render', renderServiceRuntime);document.addEventListener('click', function(event) {var target = event.target.closest('[data-account-service-action]');diff --git a/internal/cloudcp/portal/assets/portal_shell.js b/internal/cloudcp/portal/assets/portal_shell.jsindex 53719d320b..f2fa135623 100644--- a/internal/cloudcp/portal/assets/portal_shell.js+++ b/internal/cloudcp/portal/assets/portal_shell.js@@ -11,10 +11,19 @@ if (bootstrapEl) {var LICENSE_API_BASE = portalBootstrap.commercial_api_base_url || '';var PORTAL_PATH = portalBootstrap.portal_path || '/portal';var BOOTSTRAP_PATH = portalBootstrap.bootstrap_path || '/api/portal/bootstrap';+var MAGIC_LINK_REQUEST_PATH = portalBootstrap.magic_link_request_path || '/api/public/magic-link/request';+var SIGNUP_PATH = portalBootstrap.signup_path || '/signup';var LOGOUT_PATH = portalBootstrap.logout_path || '/auth/logout';var ACCOUNT_API_BASE_PATH = portalBootstrap.account_api_base_path || '/api/accounts';var PORTAL_API_BASE_PATH = portalBootstrap.portal_api_base_path || '/api/portal';+var loginState = {+ emailValue: '',+ sending: false,+ success: false,+ error: '',+};+function escapeHTML(value) {return String(value || '').replace(/&/g, '&')@@ -42,13 +51,47 @@ function roleBadgeHTML(role) {return '';}+function anonymousBootstrap() {+ return {+ authenticated: false,+ email: '',+ public_site_url: portalBootstrap.public_site_url || 'https://pulserelay.pro',+ support_email: portalBootstrap.support_email || '[email protected]',+ commercial_api_base_url: LICENSE_API_BASE,+ portal_path: PORTAL_PATH,+ bootstrap_path: BOOTSTRAP_PATH,+ magic_link_request_path: MAGIC_LINK_REQUEST_PATH,+ signup_path: SIGNUP_PATH,+ logout_path: LOGOUT_PATH,+ account_api_base_path: ACCOUNT_API_BASE_PATH,+ portal_api_base_path: PORTAL_API_BASE_PATH,+ accounts: [],+ };+}++function renderHeader() {+ var userInfo = document.getElementById('portal-user-info');+ if (!userInfo) return;+ if (portalBootstrap.authenticated) {+ userInfo.innerHTML =+ '<span>' + escapeHTML(portalBootstrap.email || '') + '</span>' ++ '<button class="logout-btn" id="logout-btn" type="button">Sign out</button>';+ return;+ }+ userInfo.innerHTML =+ '<a class="logout-btn" href="' + escapeAttr(SIGNUP_PATH) + '" style="text-decoration:none">Create account</a>';+}+function renderWorkspaceCard(account, workspace) {var state = String(workspace.state || '');var safeState = escapeHTML(state);var createdLabel = formatWorkspaceDate(workspace.created_at);var openAction = '';if (state === 'active') {- openAction = '<form method="POST" action="' + escapeAttr(ACCOUNT_API_BASE_PATH + '/' + account.id + '/tenants/' + workspace.id + '/handoff') + '">' ++ openAction =+ '<form method="POST" action="' ++ escapeAttr(ACCOUNT_API_BASE_PATH + '/' + account.id + '/tenants/' + workspace.id + '/handoff') ++ '">' +'<button type="submit" class="btn-primary">Open →</button>' +'</form>';} else {@@ -57,11 +100,20 @@ function renderWorkspaceCard(account, workspace) {var manageAction = '';if (account.can_manage && (state === 'active' || state === 'suspended' || state === 'failed')) {- manageAction = '<button type="button" class="btn-danger" data-action="workspace-manage" data-account-id="' + escapeAttr(account.id) + '" data-workspace-id="' + escapeAttr(workspace.id) + '" data-workspace-state="' + escapeAttr(state) + '" data-workspace-name="' + escapeAttr(workspace.display_name) + '">⋯</button>';+ manageAction =+ '<button type="button" class="btn-danger" data-action="workspace-manage" data-account-id="' ++ escapeAttr(account.id) ++ '" data-workspace-id="' ++ escapeAttr(workspace.id) ++ '" data-workspace-state="' ++ escapeAttr(state) ++ '" data-workspace-name="' ++ escapeAttr(workspace.display_name) ++ '">⋯</button>';}var createdMeta = createdLabel ? '<span class="ws-created">Created ' + escapeHTML(createdLabel) + '</span>' : '';- return '' ++ return ('<div class="workspace-card">' +'<div class="ws-info">' +'<span class="ws-name">' + escapeHTML(workspace.display_name) + '</span>' +@@ -77,7 +129,8 @@ function renderWorkspaceCard(account, workspace) {openAction +manageAction +'</div>' +- '</div>';+ '</div>'+ );}function renderAccountSection(account) {@@ -86,56 +139,98 @@ function renderAccountSection(account) {if (workspaces.length === 0) {workspaceHTML = '<div class="empty-state"><p>No workspaces yet. Create one to get started.</p></div>';} else {- workspaceHTML = '<div class="workspace-list">' + workspaces.map(function(workspace) {- return renderWorkspaceCard(account, workspace);- }).join('') + '</div>';+ workspaceHTML =+ '<div class="workspace-list">' ++ workspaces.map(function(workspace) {+ return renderWorkspaceCard(account, workspace);+ }).join('') ++ '</div>';}var actions = '';var teamSection = '';var addWorkspaceForm = '';if (account.can_manage) {- actions = '<div class="account-actions">' ++ actions =+ '<div class="account-actions">' +(account.kind === 'msp'- ? '<button type="button" class="btn-secondary" id="add-ws-btn-' + escapeAttr(account.id) + '" data-action="toggle-add-workspace" data-account-id="' + escapeAttr(account.id) + '">+ Add workspace</button>'+ ? '<button type="button" class="btn-secondary" id="add-ws-btn-' ++ escapeAttr(account.id) ++ '" data-action="toggle-add-workspace" data-account-id="' ++ escapeAttr(account.id) ++ '">+ Add workspace</button>': '') +(account.has_billing- ? '<button type="button" class="btn-secondary" data-action="open-billing" data-account-id="' + escapeAttr(account.id) + '">Manage billing</button>'+ ? '<button type="button" class="btn-secondary" data-action="open-billing" data-account-id="' ++ escapeAttr(account.id) ++ '">Manage billing</button>': '') +- '<button type="button" class="btn-secondary" id="team-btn-' + escapeAttr(account.id) + '" data-action="toggle-team" data-account-id="' + escapeAttr(account.id) + '">Manage team</button>' +- '</div>';-- teamSection = '' +- '<div class="team-section" id="team-section-' + escapeAttr(account.id) + '" data-actor-role="' + escapeAttr(account.role) + '">' +- '<h3>Team members</h3>' +- '<table class="team-table">' +- '<thead><tr><th>Email</th><th>Role</th><th></th></tr></thead>' +- '<tbody id="team-list-' + escapeAttr(account.id) + '">' +- '<tr><td colspan="3" style="color:#94a3b8;text-align:center;padding:16px">Loading…</td></tr>' +- '</tbody>' +- '</table>' +- '<div class="team-invite">' +- '<div><label for="invite-email-' + escapeAttr(account.id) + '">Email</label><input type="email" id="invite-email-' + escapeAttr(account.id) + '" placeholder="[email protected]" autocomplete="off"></div>' +- '<div><label for="invite-role-' + escapeAttr(account.id) + '">Role</label><select id="invite-role-' + escapeAttr(account.id) + '"><option value="admin">Admin</option><option value="tech">Tech</option><option value="read_only">Read-only</option></select></div>' +- '<button type="button" class="btn-primary" style="padding:8px 14px;font-size:13px" data-action="invite-member" data-account-id="' + escapeAttr(account.id) + '">Invite</button>' +- '</div>' ++ '<button type="button" class="btn-secondary" id="team-btn-' ++ escapeAttr(account.id) ++ '" data-action="toggle-team" data-account-id="' ++ escapeAttr(account.id) ++ '">Manage team</button>' ++ '</div>';++ teamSection =+ '<div class="team-section" id="team-section-' ++ escapeAttr(account.id) ++ '" data-actor-role="' ++ escapeAttr(account.role) ++ '">' ++ '<h3>Team members</h3>' ++ '<table class="team-table">' ++ '<thead><tr><th>Email</th><th>Role</th><th></th></tr></thead>' ++ '<tbody id="team-list-' ++ escapeAttr(account.id) ++ '">' ++ '<tr><td colspan="3" style="color:#94a3b8;text-align:center;padding:16px">Loading…</td></tr>' ++ '</tbody>' ++ '</table>' ++ '<div class="team-invite">' ++ '<div><label for="invite-email-' ++ escapeAttr(account.id) ++ '">Email</label><input type="email" id="invite-email-' ++ escapeAttr(account.id) ++ '" placeholder="[email protected]" autocomplete="off"></div>' ++ '<div><label for="invite-role-' ++ escapeAttr(account.id) ++ '">Role</label><select id="invite-role-' ++ escapeAttr(account.id) ++ '"><option value="admin">Admin</option><option value="tech">Tech</option><option value="read_only">Read-only</option></select></div>' ++ '<button type="button" class="btn-primary" style="padding:8px 14px;font-size:13px" data-action="invite-member" data-account-id="' ++ escapeAttr(account.id) ++ '">Invite</button>' ++ '</div>' +'</div>';if (account.kind === 'msp') {- addWorkspaceForm = '' +- '<div class="add-workspace-form" id="add-ws-form-' + escapeAttr(account.id) + '">' +- '<label for="ws-name-' + escapeAttr(account.id) + '">Workspace name (e.g. client name)</label>' +- '<input type="text" id="ws-name-' + escapeAttr(account.id) + '" placeholder="Acme Corp" maxlength="80" autocomplete="off">' +- '<div class="form-actions">' +- '<button type="button" class="btn-primary" data-action="create-workspace" data-account-id="' + escapeAttr(account.id) + '">Create workspace</button>' +- '<button type="button" class="btn-secondary" data-action="toggle-add-workspace" data-account-id="' + escapeAttr(account.id) + '">Cancel</button>' +- '<div class="spinner" id="ws-spinner-' + escapeAttr(account.id) + '"></div>' +- '</div>' ++ addWorkspaceForm =+ '<div class="add-workspace-form" id="add-ws-form-' ++ escapeAttr(account.id) ++ '">' ++ '<label for="ws-name-' ++ escapeAttr(account.id) ++ '">Workspace name (e.g. client name)</label>' ++ '<input type="text" id="ws-name-' ++ escapeAttr(account.id) ++ '" placeholder="Acme Corp" maxlength="80" autocomplete="off">' ++ '<div class="form-actions">' ++ '<button type="button" class="btn-primary" data-action="create-workspace" data-account-id="' ++ escapeAttr(account.id) ++ '">Create workspace</button>' ++ '<button type="button" class="btn-secondary" data-action="toggle-add-workspace" data-account-id="' ++ escapeAttr(account.id) ++ '">Cancel</button>' ++ '<div class="spinner" id="ws-spinner-' ++ escapeAttr(account.id) ++ '"></div>' ++ '</div>' +'</div>';}}- return '' ++ return ('<section class="account-section">' +'<div class="account-header">' +'<h2>' + escapeHTML(account.name) + '</h2>' +@@ -146,7 +241,8 @@ function renderAccountSection(account) {actions +teamSection +addWorkspaceForm +- '</section>';+ '</section>'+ );}function renderAccounts(accounts) {@@ -154,25 +250,135 @@ function renderAccounts(accounts) {if (!root) return;var safeAccounts = Array.isArray(accounts) ? accounts : [];if (safeAccounts.length === 0) {- root.innerHTML = '' ++ root.innerHTML ='<div class="empty-state" style="margin-top:48px">' +'<p>No workspaces found. If you just signed up, check your email for setup instructions.</p>' +- '<p style="margin-top:12px;font-size:13px">Need help? Contact <a href="mailto:' + escapeAttr(portalBootstrap.support_email || '') + '" style="color:#1d4ed8">' + escapeHTML(portalBootstrap.support_email || '') + '</a></p>' ++ '<p style="margin-top:12px;font-size:13px">Need help? Contact <a href="mailto:' ++ escapeAttr(portalBootstrap.support_email || '') ++ '" style="color:#1d4ed8">' ++ escapeHTML(portalBootstrap.support_email || '') ++ '</a></p>' +'</div>';return;}root.innerHTML = safeAccounts.map(renderAccountSection).join('');}+function renderAuthenticatedPortal() {+ return (+ '<section class="intro-card">' ++ '<h1>Pulse Account</h1>' ++ '<p>Manage Cloud workspaces, MSP access, and self-hosted commercial account services from one account surface. Hosted workspace lifecycle lives here today, and the self-hosted billing, license recovery, refund, and privacy tools below now share the same Pulse Account shell instead of staying fragmented across public utility pages.</p>' ++ '</section>' ++ '<div id="accounts-root"></div>' ++ '<section class="service-section">' ++ '<div class="service-header">' ++ '<h2>Other account services</h2>' ++ '<div class="service-note">Self-hosted commercial account actions now live here. The public utility pages remain as compatibility entry points, not the primary account surface.</div>' ++ '</div>' ++ '<div class="service-grid">' ++ '<button class="service-card service-card-button" type="button" id="open-manage-service" data-account-service-action="open-service-panel" data-account-service-panel="manage-service-panel" data-account-service-focus="manage-inline-email">' ++ '<h3>Manage subscriptions</h3>' ++ '<p>Open Stripe billing access for existing self-hosted subscriptions without leaving the Pulse Account shell.</p>' ++ '</button>' ++ '<button class="service-card service-card-button" type="button" id="open-retrieve-service" data-account-service-action="open-service-panel" data-account-service-panel="retrieve-service-panel" data-account-service-focus="retrieve-inline-email">' ++ '<h3>Retrieve licenses</h3>' ++ '<p>Recover the latest active self-hosted license and invoice link for a commercial email address.</p>' ++ '</button>' ++ '<button class="service-card service-card-button" type="button" id="open-refund-service" data-account-service-action="open-service-panel" data-account-service-panel="refund-service-panel" data-account-service-focus="refund-inline-email">' ++ '<h3>Refund requests</h3>' ++ '<p>Request an immediate self-serve refund for eligible self-hosted purchases with explicit revocation confirmation.</p>' ++ '</button>' ++ '<button class="service-card service-card-button" type="button" id="open-data-service" data-account-service-action="open-service-panel" data-account-service-panel="data-service-panel" data-account-service-focus="data-export-email">' ++ '<h3>Data and privacy</h3>' ++ '<p>Request commercial data export or deletion without leaving the account shell.</p>' ++ '</button>' ++ '</div>' ++ '<div class="service-panel" id="manage-service-panel"><div id="manage-service-root"></div></div>' ++ '<div class="service-panel" id="retrieve-service-panel"><div id="retrieve-service-root"></div></div>' ++ '<div class="service-panel" id="refund-service-panel"><div id="refund-service-root"></div></div>' ++ '<div class="service-panel" id="data-service-panel">' ++ '<h3>Data and privacy</h3>' ++ '<p>Request export or deletion of the commercial data tied to an email address. Payment data held directly by Stripe still requires support handling.</p>' ++ '<div class="subsection"><div id="data-export-root"></div></div>' ++ '<div class="subsection"><div id="data-delete-root"></div></div>' ++ '<div class="helper-text">Payment-card data stays with Stripe. For Stripe deletion support, contact <a href="mailto:' ++ escapeAttr(portalBootstrap.support_email || '') ++ '">' ++ escapeHTML(portalBootstrap.support_email || '') ++ '</a>.</div>' ++ '</div>' ++ '</section>'+ );+}++function renderSignedOutPortal() {+ var statusHTML = '';+ if (loginState.error) {+ statusHTML = '<div class="service-status visible error">' + escapeHTML(loginState.error) + '</div>';+ } else if (loginState.success) {+ statusHTML =+ '<div class="service-status visible success">' ++ 'Magic link sent. Check your inbox and click the link to sign in.' ++ '<br><br><strong>Don\'t see it?</strong> <a href="#" data-portal-action="resend-magic-link">Send a new link</a>.' ++ '</div>';+ }+ return (+ '<section class="intro-card">' ++ '<h1>Pulse Account</h1>' ++ '<p>Sign in to manage Cloud workspaces, MSP access, and commercial account services from one account surface.</p>' ++ '</section>' ++ '<section class="service-section">' ++ '<div class="service-panel visible">' ++ '<h3>Sign in</h3>' ++ '<p>Enter the commercial email address for your Pulse account. I will send a magic link so you can open Pulse Account without managing a password.</p>' ++ '<div class="form-group">' ++ '<label for="portal-login-email">Email address</label>' ++ '<input id="portal-login-email" type="email" autocomplete="email" placeholder="[email protected]" value="' ++ escapeAttr(loginState.emailValue || '') ++ '" data-portal-input="login-email">' ++ '</div>' ++ '<div class="form-actions">' ++ '<button class="btn-primary" id="portal-login-send" type="button" data-portal-action="send-magic-link">' ++ (loginState.sending ? 'Sending…' : 'Send magic link') ++ '</button>' ++ '<a class="btn-secondary" href="' + escapeAttr(SIGNUP_PATH) + '" style="text-decoration:none">Create an account</a>' ++ '</div>' ++ statusHTML ++ '</div>' ++ '</section>'+ );+}++function dispatchPortalRender() {+ document.dispatchEvent(new CustomEvent('pulse-account-render'));+}++function renderPortalApp() {+ renderHeader();+ var root = document.getElementById('portal-app-root');+ if (!root) return;+ root.innerHTML = portalBootstrap.authenticated ? renderAuthenticatedPortal() : renderSignedOutPortal();+ if (portalBootstrap.authenticated) {+ renderAccounts(portalBootstrap.accounts || []);+ }+ dispatchPortalRender();+}+function applyBootstrap(data) {- portalBootstrap = data || {};+ portalBootstrap = data || anonymousBootstrap();LICENSE_API_BASE = portalBootstrap.commercial_api_base_url || LICENSE_API_BASE;PORTAL_PATH = portalBootstrap.portal_path || PORTAL_PATH;BOOTSTRAP_PATH = portalBootstrap.bootstrap_path || BOOTSTRAP_PATH;+ MAGIC_LINK_REQUEST_PATH = portalBootstrap.magic_link_request_path || MAGIC_LINK_REQUEST_PATH;+ SIGNUP_PATH = portalBootstrap.signup_path || SIGNUP_PATH;LOGOUT_PATH = portalBootstrap.logout_path || LOGOUT_PATH;ACCOUNT_API_BASE_PATH = portalBootstrap.account_api_base_path || ACCOUNT_API_BASE_PATH;PORTAL_API_BASE_PATH = portalBootstrap.portal_api_base_path || PORTAL_API_BASE_PATH;- renderAccounts(portalBootstrap.accounts || []);+ if (!portalBootstrap.authenticated && !loginState.emailValue) {+ loginState.emailValue = portalBootstrap.email || '';+ }+ renderPortalApp();}async function refreshBootstrap() {@@ -181,6 +387,10 @@ async function refreshBootstrap() {var response = await fetch(BOOTSTRAP_PATH, {headers: { 'Accept': 'application/json' }});+ if (response.status === 401) {+ applyBootstrap(anonymousBootstrap());+ return true;+ }if (!response.ok) return false;var data = await response.json();applyBootstrap(data);@@ -191,12 +401,56 @@ async function refreshBootstrap() {function showToast(msg, isError) {var t = document.getElementById('toast');+ if (!t) return;t.textContent = msg;t.className = 'toast visible' + (isError ? ' error' : '');clearTimeout(t._timer);t._timer = setTimeout(function() { t.className = 'toast'; }, 4000);}+function resetLoginState(options) {+ loginState.sending = false;+ loginState.error = '';+ loginState.success = false;+ if (options && options.keepEmail) return;+ loginState.emailValue = '';+}++async function sendMagicLink() {+ var email = String(loginState.emailValue || '').trim();+ if (!email) {+ var input = document.getElementById('portal-login-email');+ if (input) input.focus();+ return;+ }+ loginState.sending = true;+ loginState.error = '';+ loginState.success = false;+ renderPortalApp();+ try {+ var response = await fetch(MAGIC_LINK_REQUEST_PATH, {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ body: JSON.stringify({ email: email })+ });+ if (response.ok || response.status === 404) {+ loginState.sending = false;+ loginState.success = true;+ renderPortalApp();+ return;+ }+ if (response.status === 429) {+ loginState.error = 'Too many requests. Please wait a moment and try again.';+ } else {+ loginState.error = 'Something went wrong. Please try again.';+ }+ } catch (_) {+ loginState.error = 'Network error. Please check your connection and try again.';+ }+ loginState.sending = false;+ renderPortalApp();+}+window.PulseAccountPortal = {getBootstrap: function() {return portalBootstrap;@@ -217,19 +471,41 @@ window.PulseAccountPortal = {showToast: showToast,};-document.getElementById('logout-btn').onclick = async function() {- this.disabled = true;- this.textContent = 'Signing out…';- try {- await fetch(LOGOUT_PATH, { method: 'POST' });- } catch(_) {}- window.location.href = PORTAL_PATH;-};+document.addEventListener('click', function(event) {+ var portalActionEl = event.target.closest('[data-portal-action]');+ if (portalActionEl) {+ var portalAction = portalActionEl.getAttribute('data-portal-action') || '';+ switch (portalAction) {+ case 'send-magic-link':+ event.preventDefault();+ sendMagicLink();+ return;+ case 'resend-magic-link':+ event.preventDefault();+ loginState.success = false;+ loginState.error = '';+ renderPortalApp();+ sendMagicLink();+ return;+ default:+ break;+ }+ }-applyBootstrap(portalBootstrap);-refreshBootstrap();+ var logoutBtn = event.target.closest('#logout-btn');+ if (logoutBtn) {+ event.preventDefault();+ logoutBtn.disabled = true;+ logoutBtn.textContent = 'Signing out…';+ (async function() {+ try {+ await fetch(LOGOUT_PATH, { method: 'POST' });+ } catch (_) {}+ window.location.href = PORTAL_PATH;+ })();+ return;+ }-document.addEventListener('click', function(event) {var actionEl = event.target.closest('[data-action]');if (!actionEl) return;var action = actionEl.getAttribute('data-action') || '';@@ -289,21 +565,32 @@ document.addEventListener('change', function(event) {);});+document.addEventListener('input', function(event) {+ var target = event.target;+ if (!target) return;+ if (target.getAttribute('data-portal-input') === 'login-email') {+ loginState.emailValue = target.value;+ }+});+function toggleAddWorkspace(accountID) {var form = document.getElementById('add-ws-form-' + accountID);+ if (!form) return;var visible = form.classList.contains('visible');form.classList.toggle('visible', !visible);if (!visible) {- document.getElementById('ws-name-' + accountID).focus();+ var input = document.getElementById('ws-name-' + accountID);+ if (input) input.focus();}}async function createWorkspace(accountID) {var nameEl = document.getElementById('ws-name-' + accountID);+ if (!nameEl) return;var name = nameEl.value.trim();if (!name) { nameEl.focus(); return; }var spinner = document.getElementById('ws-spinner-' + accountID);- spinner.style.display = 'block';+ if (spinner) spinner.style.display = 'block';try {var resp = await fetch(ACCOUNT_API_BASE_PATH + '/' + accountID + '/tenants', {method: 'POST',@@ -320,10 +607,10 @@ async function createWorkspace(accountID) {return;}showToast('Workspace created!');- } catch(e) {+ } catch (_) {showToast('Network error. Please try again.', true);} finally {- spinner.style.display = 'none';+ if (spinner) spinner.style.display = 'none';}}@@ -348,7 +635,7 @@ async function suspendOrDelete(evt, accountID, tenantID, state, name) {return;}showToast(action + 'd workspace.');- } catch(_) {+ } catch (_) {showToast('Network error.', true);}}@@ -367,7 +654,7 @@ async function openBilling(accountID) {} else {showToast('Failed to open billing portal.', true);}- } catch(e) {+ } catch (_) {showToast('Network error.', true);}}@@ -406,8 +693,8 @@ async function loadTeam(accountID) {setTbodyMessage(tbody, 'No team members.', false);return;}- var allRoles = ['owner','admin','tech','read_only'];- var nonOwnerRoles = ['admin','tech','read_only'];+ var allRoles = ['owner', 'admin', 'tech', 'read_only'];+ var nonOwnerRoles = ['admin', 'tech', 'read_only'];tbody.textContent = '';for (var i = 0; i < members.length; i++) {(function(m) {@@ -450,7 +737,7 @@ async function loadTeam(accountID) {tbody.appendChild(tr);})(members[i]);}- } catch(e) {+ } catch (_) {setTbodyMessage(tbody, 'Network error.', true);}}@@ -472,6 +759,7 @@ async function refreshAccountTeamSection(accountID) {async function inviteMember(accountID) {var emailEl = document.getElementById('invite-email-' + accountID);var roleEl = document.getElementById('invite-role-' + accountID);+ if (!emailEl || !roleEl) return;var email = emailEl.value.trim();if (!email) { emailEl.focus(); return; }try {@@ -491,7 +779,7 @@ async function inviteMember(accountID) {return;}showToast('Member invited!');- } catch(e) {+ } catch (_) {showToast('Network error.', true);}}@@ -509,7 +797,7 @@ async function changeRole(accountID, userID, newRole) {return;}showToast('Role updated.');- } catch(e) {+ } catch (_) {showToast('Network error.', true);loadTeam(accountID);}@@ -527,7 +815,13 @@ async function removeMember(accountID, userID, email) {return;}showToast('Member removed.');- } catch(e) {+ } catch (_) {showToast('Network error.', true);}}++loginState.emailValue = portalBootstrap.email || '';+applyBootstrap(portalBootstrap);+if (portalBootstrap.authenticated) {+ refreshBootstrap();+}diff --git a/internal/cloudcp/portal/bootstrap.go b/internal/cloudcp/portal/bootstrap.goindex 0e098683fd..e947e496c9 100644--- a/internal/cloudcp/portal/bootstrap.go+++ b/internal/cloudcp/portal/bootstrap.go@@ -26,27 +26,30 @@ type BootstrapAccount struct {}type BootstrapData struct {+ Authenticated bool `json:"authenticated"`Email string `json:"email"`PublicSiteURL string `json:"public_site_url"`SupportEmail string `json:"support_email"`CommercialAPIBaseURL string `json:"commercial_api_base_url"`PortalPath string `json:"portal_path"`BootstrapPath string `json:"bootstrap_path"`+ MagicLinkRequestPath string `json:"magic_link_request_path"`+ SignupPath string `json:"signup_path"`LogoutPath string `json:"logout_path"`AccountAPIBasePath string `json:"account_api_base_path"`PortalAPIBasePath string `json:"portal_api_base_path"`Accounts []BootstrapAccount `json:"accounts"`}-func MarshalBootstrapJSON(email string, accounts []portalPageAccount) (template.JS, error) {- payload, err := json.Marshal(BuildBootstrapData(email, accounts))+func MarshalBootstrapJSON(data BootstrapData) (template.JS, error) {+ payload, err := json.Marshal(data)if err != nil {return "", err}return template.JS(payload), nil}-func BuildBootstrapData(email string, accounts []portalPageAccount) BootstrapData {+func BuildBootstrapData(authenticated bool, email string, accounts []portalPageAccount) BootstrapData {bootstrapAccounts := make([]BootstrapAccount, 0, len(accounts))for _, account := range accounts {workspaces := make([]BootstrapWorkspace, 0, len(account.Workspaces))@@ -72,15 +75,22 @@ func BuildBootstrapData(email string, accounts []portalPageAccount) BootstrapDat}return BootstrapData{+ Authenticated: authenticated,Email: email,PublicSiteURL: defaultPublicSiteURL,SupportEmail: defaultSupportEmail,CommercialAPIBaseURL: defaultCommercialAPIBaseURL,PortalPath: defaultPortalPath,BootstrapPath: PortalBootstrapPath,+ MagicLinkRequestPath: PortalMagicLinkRequestPath,+ SignupPath: PortalSignupPath,LogoutPath: defaultLogoutPath,AccountAPIBasePath: defaultAccountAPIBasePath,PortalAPIBasePath: defaultPortalAPIBasePath,Accounts: bootstrapAccounts,}}++func BuildAnonymousBootstrapData() BootstrapData {+ return BuildBootstrapData(false, "", nil)+}diff --git a/internal/cloudcp/portal/handlers.go b/internal/cloudcp/portal/handlers.goindex 95ba89fe2f..f4e51a621d 100644--- a/internal/cloudcp/portal/handlers.go+++ b/internal/cloudcp/portal/handlers.go@@ -241,7 +241,7 @@ func HandlePortalBootstrap(sessionSvc *cpauth.Service, reg *registry.TenantRegisw.Header().Set("Content-Type", "application/json")w.WriteHeader(http.StatusOK)- encodeJSON(w, BuildBootstrapData(claims.Email, accounts))+ encodeJSON(w, BuildBootstrapData(true, claims.Email, accounts))}}diff --git a/internal/cloudcp/portal/handlers_test.go b/internal/cloudcp/portal/handlers_test.goindex fc12898a28..a3d45d8ea3 100644--- a/internal/cloudcp/portal/handlers_test.go+++ b/internal/cloudcp/portal/handlers_test.go@@ -3,7 +3,6 @@ package portalimport ("encoding/json""fmt"- "html/template""net/http""net/http/httptest""sort"@@ -43,26 +42,16 @@ func doRequest(t *testing.T, h http.Handler, req *http.Request) *httptest.Responreturn rec}-func renderPortalHTML(t *testing.T, data portalPageData) string {+func renderPortalHTML(t *testing.T, bootstrap BootstrapData) string {t.Helper()rec := httptest.NewRecorder()- renderPortalPage(rec, data.Nonce, data.Email, data.Accounts)+ renderPortalPage(rec, "test-nonce", bootstrap)if rec.Code != http.StatusOK {t.Fatalf("renderPortalPage returned %d", rec.Code)}return rec.Body.String()}-func renderLoginHTML(t *testing.T, nonce string) string {- t.Helper()- rec := httptest.NewRecorder()- renderLoginPage(rec, nonce)- if rec.Code != http.StatusOK {- t.Fatalf("renderLoginPage returned %d", rec.Code)- }- return rec.Body.String()-}-func extractPortalBootstrapJSONFromHTML(t *testing.T, html string) string {t.Helper()startMarker := `<script id="pulse-account-bootstrap" type="application/json">`@@ -663,137 +652,151 @@ func TestBillingPortalRedirect_EmptyURL(t *testing.T) {// --- Portal page template rendering tests ---func TestPortalPageTemplate_TeamManagementRendered(t *testing.T) {- // Verify that accounts with CanManage=true render team management UI markup.- data := portalPageData{- Nonce: "test-nonce",- Email: "[email protected]",- Accounts: []portalPageAccount{- {- ID: "a_managed",- Kind: "cloud",- KindLabel: "Cloud",- Name: "My Cloud Account",- Role: "owner",- CanManage: true,- HasBilling: false,- Workspaces: nil,- },+ html := renderPortalHTML(t, BuildBootstrapData(true, "[email protected]", []portalPageAccount{+ {+ ID: "a_managed",+ Kind: "cloud",+ KindLabel: "Cloud",+ Name: "My Cloud Account",+ Role: "owner",+ CanManage: true,+ HasBilling: false,},- }-- html := renderPortalHTML(t, data)+ }))- // Account-specific markup (only rendered when CanManage=true).mustContain := []string{- `id="team-btn-a_managed"`, // team button with account ID- `id="team-section-a_managed"`, // team section div- `data-actor-role="owner"`, // actor role data attribute- "Team members", // section heading- `id="team-list-a_managed"`, // member list tbody- `id="invite-email-a_managed"`, // invite email input- `id="invite-role-a_managed"`, // invite role select+ `id="portal-app-root"`,+ `if (account.can_manage) {`,+ `data-actor-role="`,+ `id="team-list-`,`data-action="toggle-team"`,`data-action="invite-member"`,- `data-account-id="a_managed"`,}for _, needle := range mustContain {if !strings.Contains(html, needle) {t.Errorf("expected %q in rendered HTML", needle)}}++ var payload map[string]any+ if err := json.Unmarshal([]byte(extractPortalBootstrapJSONFromHTML(t, html)), &payload); err != nil {+ t.Fatalf("unmarshal bootstrap JSON: %v", err)+ }+ if got := payload["authenticated"]; got != true {+ t.Fatalf("authenticated = %#v, want true", got)+ }+ accounts, ok := payload["accounts"].([]any)+ if !ok || len(accounts) != 1 {+ t.Fatalf("accounts = %#v, want one account", payload["accounts"])+ }+ account, ok := accounts[0].(map[string]any)+ if !ok {+ t.Fatalf("account = %#v", accounts[0])+ }+ if got := account["can_manage"]; got != true {+ t.Fatalf("can_manage = %#v, want true", got)+ }+ if got := account["role"]; got != "owner" {+ t.Fatalf("role = %#v, want owner", got)+ }}func TestPortalPageTemplate_TeamManagementHiddenForNonManagers(t *testing.T) {- // Accounts with CanManage=false should NOT render team management markup.- data := portalPageData{- Nonce: "test-nonce",- Email: "[email protected]",- Accounts: []portalPageAccount{- {- ID: "a_readonly",- Kind: "cloud",- KindLabel: "Cloud",- Name: "Readonly Account",- Role: "read_only",- CanManage: false,- HasBilling: false,- Workspaces: nil,- },+ html := renderPortalHTML(t, BuildBootstrapData(true, "[email protected]", []portalPageAccount{+ {+ ID: "a_readonly",+ Kind: "cloud",+ KindLabel: "Cloud",+ Name: "Readonly Account",+ Role: "read_only",+ CanManage: false,+ HasBilling: false,},- }-- html := renderPortalHTML(t, data)+ }))- // Account-specific team markup must NOT appear.- mustNotContain := []string{- `id="team-btn-a_readonly"`,- `id="team-section-a_readonly"`,- `id="invite-email-a_readonly"`,+ var payload map[string]any+ if err := json.Unmarshal([]byte(extractPortalBootstrapJSONFromHTML(t, html)), &payload); err != nil {+ t.Fatalf("unmarshal bootstrap JSON: %v", err)}- for _, needle := range mustNotContain {- if strings.Contains(html, needle) {- t.Errorf("%q should NOT appear for non-manager accounts", needle)- }+ accounts, ok := payload["accounts"].([]any)+ if !ok || len(accounts) != 1 {+ t.Fatalf("accounts = %#v, want one account", payload["accounts"])+ }+ account, ok := accounts[0].(map[string]any)+ if !ok {+ t.Fatalf("account = %#v", accounts[0])+ }+ if got := account["can_manage"]; got != false {+ t.Fatalf("can_manage = %#v, want false", got)+ }+ if got := account["role"]; got != "read_only" {+ t.Fatalf("role = %#v, want read_only", got)}}func TestPortalPageTemplate_ActorRolePassedToSection(t *testing.T) {- // Verify the actor role is passed as a data attribute for JS permission checks.for _, role := range []string{"owner", "admin"} {t.Run(role, func(t *testing.T) {- data := portalPageData{- Nonce: "n",- Email: "[email protected]",- Accounts: []portalPageAccount{- {- ID: "a_test",- Kind: "cloud",- KindLabel: "Cloud",- Name: "Test",- Role: role,- CanManage: true,- },+ html := renderPortalHTML(t, BuildBootstrapData(true, "[email protected]", []portalPageAccount{+ {+ ID: "a_test",+ Kind: "cloud",+ KindLabel: "Cloud",+ Name: "Test",+ Role: role,+ CanManage: true,},+ }))+ if !strings.Contains(html, `data-actor-role="`) {+ t.Fatalf("expected actor-role render seam in portal shell")+ }+ var payload map[string]any+ if err := json.Unmarshal([]byte(extractPortalBootstrapJSONFromHTML(t, html)), &payload); err != nil {+ t.Fatalf("unmarshal bootstrap JSON: %v", err)}- html := renderPortalHTML(t, data)- if !strings.Contains(html, `data-actor-role="`+role+`"`) {- t.Errorf("expected data-actor-role=%q in rendered HTML", role)+ accounts, ok := payload["accounts"].([]any)+ if !ok || len(accounts) != 1 {+ t.Fatalf("accounts = %#v, want one account", payload["accounts"])+ }+ account, ok := accounts[0].(map[string]any)+ if !ok {+ t.Fatalf("account = %#v", accounts[0])+ }+ if got := account["role"]; got != role {+ t.Fatalf("role = %#v, want %q", got, role)}})}}func TestPortalPageTemplate_AccountServicesRendered(t *testing.T) {- data := portalPageData{- Nonce: "test-nonce",- Email: "[email protected]",- PublicSiteURL: "https://pulserelay.pro",- SupportEmail: "[email protected]",- Accounts: []portalPageAccount{- {- ID: "a_test",- Kind: "cloud",- KindLabel: "Cloud",- Name: "Test Account",- },+ html := renderPortalHTML(t, BuildBootstrapData(true, "[email protected]", []portalPageAccount{+ {+ ID: "a_test",+ Kind: "cloud",+ KindLabel: "Cloud",+ Name: "Test Account",},- }-- html := renderPortalHTML(t, data)+ }))mustContain := []string{"<title>Pulse Account</title>",- "Pulse Account",- `id="accounts-root"`,+ `id="portal-user-info"`,+ `id="portal-app-root"`,`id="pulse-account-bootstrap"`,+ `"authenticated":true`,`"commercial_api_base_url":"https://license.pulserelay.pro"`,fmt.Sprintf(`"portal_path":"%s"`, PortalPagePath),fmt.Sprintf(`"bootstrap_path":"%s"`, PortalBootstrapPath),+ fmt.Sprintf(`"magic_link_request_path":"%s"`, PortalMagicLinkRequestPath),+ fmt.Sprintf(`"signup_path":"%s"`, PortalSignupPath),fmt.Sprintf(`"logout_path":"%s"`, PortalLogoutPath),fmt.Sprintf(`"account_api_base_path":"%s"`, PortalAccountAPIBasePath),fmt.Sprintf(`"portal_api_base_path":"%s"`, PortalAPIBasePath),`"email":"[email protected]"`,`"accounts":[{"id":"a_test"`,+ `renderAuthenticatedPortal()`,+ `renderSignedOutPortal()`,"Other account services",`id="open-manage-service"`,`id="open-retrieve-service"`,@@ -837,12 +840,12 @@ func TestPortalPageTemplate_AccountServicesRendered(t *testing.T) {`if (!await refreshBootstrap())`,`refreshAccountTeamSection(accountID)`,`window.PulseAccountPortal = {`,+ `document.addEventListener('pulse-account-render'`,`document.addEventListener('click'`,`document.addEventListener('change'`,`data-action="open-billing"`,`data-action="create-workspace"`,`data-action="workspace-manage"`,- `href="https://pulserelay.pro/refund.html?email=owner%40example.com"`,"commercial account actions now live here",}for _, needle := range mustContain {@@ -871,7 +874,7 @@ func TestPortalPageTemplate_AccountServicesRendered(t *testing.T) {}func TestBuildPortalBootstrapJSON_Contract(t *testing.T) {- bootstrapJSON, err := MarshalBootstrapJSON("[email protected]", []portalPageAccount{+ bootstrapJSON, err := MarshalBootstrapJSON(BuildBootstrapData(true, "[email protected]", []portalPageAccount{{ID: "a_test",Kind: "cloud",@@ -889,7 +892,7 @@ func TestBuildPortalBootstrapJSON_Contract(t *testing.T) {},},},- })+ }))if err != nil {t.Fatalf("MarshalBootstrapJSON: %v", err)}@@ -899,6 +902,9 @@ func TestBuildPortalBootstrapJSON_Contract(t *testing.T) {t.Fatalf("unmarshal bootstrap JSON: %v", err)}+ if got := payload["authenticated"]; got != true {+ t.Fatalf("authenticated = %#v, want true", got)+ }if got := payload["email"]; got != "[email protected]" {t.Fatalf("email = %#v, want [email protected]", got)}@@ -911,6 +917,12 @@ func TestBuildPortalBootstrapJSON_Contract(t *testing.T) {if got := payload["bootstrap_path"]; got != PortalBootstrapPath {t.Fatalf("bootstrap_path = %#v", got)}+ if got := payload["magic_link_request_path"]; got != PortalMagicLinkRequestPath {+ t.Fatalf("magic_link_request_path = %#v", got)+ }+ if got := payload["signup_path"]; got != PortalSignupPath {+ t.Fatalf("signup_path = %#v", got)+ }if got := payload["logout_path"]; got != PortalLogoutPath {t.Fatalf("logout_path = %#v", got)}@@ -1094,22 +1106,7 @@ func TestPortalBootstrapHTMLAndHandlerStayInSync(t *testing.T) {if err != nil {t.Fatalf("loadPortalAccountsForUser: %v", err)}- html := renderPortalHTML(t, portalPageData{- Nonce: "test-nonce",- Email: validClaims.Email,- PublicSiteURL: defaultPublicSiteURL,- SupportEmail: defaultSupportEmail,- CommercialAPIBaseURL: defaultCommercialAPIBaseURL,- PortalPath: defaultPortalPath,- LogoutPath: defaultLogoutPath,- AccountAPIBasePath: defaultAccountAPIBasePath,- PortalAPIBasePath: defaultPortalAPIBasePath,- Accounts: accounts,- Styles: portalStyles,- ShellScript: portalShellScript,- ServicesScript: portalServicesScript,- BootstrapJSON: mustBootstrapJSON(t, validClaims.Email, accounts),- })+ html := renderPortalHTML(t, BuildBootstrapData(true, validClaims.Email, accounts))handlerJSON := strings.TrimSpace(rec.Body.String())pageJSON := strings.TrimSpace(extractPortalBootstrapJSONFromHTML(t, html))@@ -1118,22 +1115,19 @@ func TestPortalBootstrapHTMLAndHandlerStayInSync(t *testing.T) {}}-func mustBootstrapJSON(t *testing.T, email string, accounts []portalPageAccount) template.JS {- t.Helper()- bootstrapJSON, err := MarshalBootstrapJSON(email, accounts)- if err != nil {- t.Fatalf("MarshalBootstrapJSON: %v", err)- }- return bootstrapJSON-}--func TestPortalLoginTemplate_UsesPulseAccountBranding(t *testing.T) {- html := renderLoginHTML(t, "test-nonce")+func TestPortalPageTemplate_UsesPulseAccountBrandingWhenSignedOut(t *testing.T) {+ html := renderPortalHTML(t, BuildAnonymousBootstrapData())mustContain := []string{- "<title>Pulse Account — Sign In</title>",+ "<title>Pulse Account</title>","Pulse Account",- "Sign in to manage Cloud workspaces, MSP access, and commercial account services.",+ `id="portal-app-root"`,+ "Enter the commercial email address for your Pulse account.",+ `"authenticated":false`,+ fmt.Sprintf(`"magic_link_request_path":"%s"`, PortalMagicLinkRequestPath),+ fmt.Sprintf(`"signup_path":"%s"`, PortalSignupPath),+ `data-portal-action="send-magic-link"`,+ `data-portal-action="resend-magic-link"`,}for _, needle := range mustContain {if !strings.Contains(html, needle) {diff --git a/internal/cloudcp/portal/page.go b/internal/cloudcp/portal/page.goindex 94e71e9fbf..c0d29d29e5 100644--- a/internal/cloudcp/portal/page.go+++ b/internal/cloudcp/portal/page.go@@ -35,26 +35,11 @@ type portalPageAccount struct {// portalPageData is passed to the portal HTML template.type portalPageData struct {- Nonce string- Email string- PublicSiteURL string- SupportEmail string- CommercialAPIBaseURL string- PortalPath string- LogoutPath string- AccountAPIBasePath string- PortalAPIBasePath string- Accounts []portalPageAccount- Styles template.CSS- ShellScript template.JS- ServicesScript template.JS- BootstrapJSON template.JS-}--type loginPageData struct {- Nonce string- Styles template.CSS- Script template.JS+ Nonce string+ Styles template.CSS+ ShellScript template.JS+ ServicesScript template.JS+ BootstrapJSON template.JS}const (@@ -83,18 +68,21 @@ func HandlePortalPage(sessionSvc *cpauth.Service, reg *registry.TenantRegistry)nonce := cpsec.NonceFromContext(r.Context())claims, err := validatePortalSessionClaims(r, sessionSvc, reg)- if err != nil {- renderLoginPage(w, nonce)- return- }- accounts, err := loadPortalAccountsForUser(reg, claims.UserID)- if err != nil {- log.Error().Err(err).Str("user_id", claims.UserID).Msg("cloudcp.portal.page: load accounts")+ switch {+ case err == nil:+ accounts, loadErr := loadPortalAccountsForUser(reg, claims.UserID)+ if loadErr != nil {+ log.Error().Err(loadErr).Str("user_id", claims.UserID).Msg("cloudcp.portal.page: load accounts")+ http.Error(w, "internal error", http.StatusInternalServerError)+ return+ }+ renderPortalPage(w, nonce, BuildBootstrapData(true, claims.Email, accounts))+ case errors.Is(err, errPortalAuthRequired):+ renderPortalPage(w, nonce, BuildAnonymousBootstrapData())+ default:+ log.Error().Err(err).Msg("cloudcp.portal.page: validate session")http.Error(w, "internal error", http.StatusInternalServerError)- return}-- renderPortalPage(w, nonce, claims.Email, accounts)}}@@ -199,42 +187,21 @@ func loadPortalAccountsForUser(reg *registry.TenantRegistry, userID string) ([]preturn accounts, nil}-func renderPortalPage(w http.ResponseWriter, nonce, email string, accounts []portalPageAccount) {+func renderPortalPage(w http.ResponseWriter, nonce string, bootstrapData BootstrapData) {w.Header().Set("Content-Type", "text/html; charset=utf-8")w.WriteHeader(http.StatusOK)- bootstrapJSON, err := MarshalBootstrapJSON(email, accounts)+ bootstrapJSON, err := MarshalBootstrapJSON(bootstrapData)if err != nil {log.Error().Err(err).Msg("cloudcp.portal.page: marshal bootstrap data")bootstrapJSON = template.JS(`{}`)}if err := portalPageTmpl.Execute(w, portalPageData{- Nonce: nonce,- Email: email,- PublicSiteURL: defaultPublicSiteURL,- SupportEmail: defaultSupportEmail,- CommercialAPIBaseURL: defaultCommercialAPIBaseURL,- PortalPath: defaultPortalPath,- LogoutPath: defaultLogoutPath,- AccountAPIBasePath: defaultAccountAPIBasePath,- PortalAPIBasePath: defaultPortalAPIBasePath,- Accounts: accounts,- Styles: portalStyles,- ShellScript: portalShellScript,- ServicesScript: portalServicesScript,- BootstrapJSON: bootstrapJSON,+ Nonce: nonce,+ Styles: portalStyles,+ ShellScript: portalShellScript,+ ServicesScript: portalServicesScript,+ BootstrapJSON: bootstrapJSON,}); err != nil {log.Error().Err(err).Msg("cloudcp.portal.page: render portal page")}}--func renderLoginPage(w http.ResponseWriter, nonce string) {- w.Header().Set("Content-Type", "text/html; charset=utf-8")- w.WriteHeader(http.StatusOK)- if err := loginPageTmpl.Execute(w, loginPageData{- Nonce: nonce,- Styles: loginStyles,- Script: loginScript,- }); err != nil {- log.Error().Err(err).Msg("cloudcp.portal.page: render login page")- }-}diff --git a/internal/cloudcp/portal/page_templates.go b/internal/cloudcp/portal/page_templates.goindex 475ca45106..81f274f030 100644--- a/internal/cloudcp/portal/page_templates.go+++ b/internal/cloudcp/portal/page_templates.go@@ -6,17 +6,14 @@ import ("io/fs")-//go:embed templates/portal.html templates/login.html assets/portal.css assets/portal_shell.js assets/portal_services.js assets/login.css assets/login.js+//go:embed templates/portal.html assets/portal.css assets/portal_shell.js assets/portal_services.jsvar portalTemplateFS embed.FSvar (portalPageTmpl = template.Must(template.ParseFS(portalTemplateFS, "templates/portal.html"))- loginPageTmpl = template.Must(template.ParseFS(portalTemplateFS, "templates/login.html"))portalStyles = mustEmbeddedCSS("assets/portal.css")portalShellScript = mustEmbeddedJS("assets/portal_shell.js")portalServicesScript = mustEmbeddedJS("assets/portal_services.js")- loginStyles = mustEmbeddedCSS("assets/login.css")- loginScript = mustEmbeddedJS("assets/login.js"))func mustEmbeddedCSS(path string) template.CSS {diff --git a/internal/cloudcp/portal/paths.go b/internal/cloudcp/portal/paths.goindex 5f2e2fa764..ef40569ea8 100644--- a/internal/cloudcp/portal/paths.go+++ b/internal/cloudcp/portal/paths.go@@ -1,12 +1,14 @@package portalconst (- PortalPagePath = "/portal"- PortalBootstrapPath = "/api/portal/bootstrap"- PortalDashboardPath = "/api/portal/dashboard"- PortalWorkspacePath = "/api/portal/workspaces/{tenant_id}"- PortalBillingPath = "/api/portal/billing"- PortalLogoutPath = "/auth/logout"- PortalAccountAPIBasePath = "/api/accounts"- PortalAPIBasePath = "/api/portal"+ PortalPagePath = "/portal"+ PortalBootstrapPath = "/api/portal/bootstrap"+ PortalDashboardPath = "/api/portal/dashboard"+ PortalWorkspacePath = "/api/portal/workspaces/{tenant_id}"+ PortalBillingPath = "/api/portal/billing"+ PortalLogoutPath = "/auth/logout"+ PortalMagicLinkRequestPath = "/api/public/magic-link/request"+ PortalSignupPath = "/signup"+ PortalAccountAPIBasePath = "/api/accounts"+ PortalAPIBasePath = "/api/portal")diff --git a/internal/cloudcp/portal/templates/login.html b/internal/cloudcp/portal/templates/login.htmldeleted file mode 100644index 8fdbe0e011..0000000000--- a/internal/cloudcp/portal/templates/login.html+++ /dev/null@@ -1,28 +0,0 @@-<!DOCTYPE html>-<html lang="en">-<head>- <meta charset="utf-8">- <meta name="viewport" content="width=device-width, initial-scale=1">- <title>Pulse Account — Sign In</title>- <style nonce="{{.Nonce}}">{{.Styles}}</style>-</head>-<body>-<div class="card">- <div class="brand">Pulse Account</div>- <div class="subtitle">Sign in to manage Cloud workspaces, MSP access, and commercial account services.</div>- <label for="email">Email address</label>- <input id="email" type="email" autocomplete="email" placeholder="[email protected]" />- <button class="cta" id="send-btn">Send magic link</button>- <div class="success" id="success">- Magic link sent! Check your inbox and click the link to sign in.- <br><br>- <strong>Don't see it?</strong> Check your spam folder, or <a href="#" id="resend-link">send a new link</a>.- </div>- <div class="error" id="err-msg"></div>- <div class="footer">- New here? <a href="/signup">Create an account</a>- </div>-</div>-<script nonce="{{.Nonce}}">{{.Script}}</script>-</body>-</html>diff --git a/internal/cloudcp/portal/templates/portal.html b/internal/cloudcp/portal/templates/portal.htmlindex 796f5f9482..1b473fcd8c 100644--- a/internal/cloudcp/portal/templates/portal.html+++ b/internal/cloudcp/portal/templates/portal.html@@ -1,3 +1,4 @@+<!DOCTYPE html><html lang="en"><head><meta charset="utf-8">@@ -8,308 +9,13 @@<body><header><span class="brand">Pulse Account</span>- <div class="user-info">- <span>{{.Email}}</span>- <button class="logout-btn" id="logout-btn">Sign out</button>- </div>+ <div class="user-info" id="portal-user-info"></div></header><script id="pulse-account-bootstrap" type="application/json">{{.BootstrapJSON}}</script><main class="main">- <section class="intro-card">- <h1>Pulse Account</h1>- <p>Manage Cloud workspaces, MSP access, and self-hosted commercial account services from one account surface. Hosted workspace lifecycle lives here today, and the self-hosted billing, license recovery, refund, and privacy tools below now share the same Pulse Account shell instead of staying fragmented across public utility pages.</p>- </section>- <div id="accounts-root">- {{if eq (len .Accounts) 0}}- <div class="empty-state" style="margin-top:48px">- <p>No workspaces found. If you just signed up, check your email for setup instructions.</p>- <p style="margin-top:12px;font-size:13px">Need help? Contact <a href="mailto:{{.SupportEmail}}" style="color:#1d4ed8">{{.SupportEmail}}</a></p>- </div>- {{else}}- {{range $ai, $account := .Accounts}}- <section class="account-section">- <div class="account-header">- <h2>{{$account.Name}}</h2>- <span class="badge badge-{{$account.Kind}}">{{$account.KindLabel}}</span>- {{if eq $account.Role "owner"}}<span class="badge" style="background:#f1f5f9;color:#64748b">Owner</span>- {{else if eq $account.Role "admin"}}<span class="badge" style="background:#f1f5f9;color:#64748b">Admin</span>- {{else if eq $account.Role "tech"}}<span class="badge" style="background:#f1f5f9;color:#64748b">Tech</span>{{end}}- </div>-- {{if eq (len $account.Workspaces) 0}}- <div class="empty-state"><p>No workspaces yet. Create one to get started.</p></div>- {{else}}- <div class="workspace-list">- {{range $wi, $ws := $account.Workspaces}}- <div class="workspace-card">- <div class="ws-info">- <span class="ws-name">{{$ws.DisplayName}}</span>- <div class="ws-meta">- {{if $ws.Healthy}}- <span class="badge badge-healthy">Healthy</span>- {{else}}- <span class="badge badge-unhealthy">Checking</span>- {{end}}- <span class="badge badge-{{$ws.State}}">{{$ws.State}}</span>- <span class="ws-created">Created {{$ws.CreatedAt.Format "Jan 2, 2006"}}</span>- </div>- </div>- <div class="ws-actions">- {{if eq $ws.State "active"}}- <form method="POST" action="{{$.AccountAPIBasePath}}/{{$account.ID}}/tenants/{{$ws.ID}}/handoff">- <button type="submit" class="btn-primary">Open →</button>- </form>- {{else}}- <span style="font-size:13px;color:#94a3b8">{{$ws.State}}</span>- {{end}}- {{if and $account.CanManage (or (eq $ws.State "active") (eq $ws.State "suspended") (eq $ws.State "failed"))}}- <button type="button" class="btn-danger" data-action="workspace-manage" data-account-id="{{$account.ID}}" data-workspace-id="{{$ws.ID}}" data-workspace-state="{{$ws.State}}" data-workspace-name="{{$ws.DisplayName}}">⋯</button>- {{end}}- </div>- </div>- {{end}}- </div>- {{end}}-- {{if $account.CanManage}}- <div class="account-actions">- {{if eq $account.Kind "msp"}}- <button type="button" class="btn-secondary" id="add-ws-btn-{{$account.ID}}" data-action="toggle-add-workspace" data-account-id="{{$account.ID}}">+ Add workspace</button>- {{end}}- {{if $account.HasBilling}}- <button type="button" class="btn-secondary" data-action="open-billing" data-account-id="{{$account.ID}}">Manage billing</button>- {{end}}- <button type="button" class="btn-secondary" id="team-btn-{{$account.ID}}" data-action="toggle-team" data-account-id="{{$account.ID}}">Manage team</button>- </div>-- <div class="team-section" id="team-section-{{$account.ID}}" data-actor-role="{{$account.Role}}">- <h3>Team members</h3>- <table class="team-table">- <thead><tr><th>Email</th><th>Role</th><th></th></tr></thead>- <tbody id="team-list-{{$account.ID}}">- <tr><td colspan="3" style="color:#94a3b8;text-align:center;padding:16px">Loading…</td></tr>- </tbody>- </table>- <div class="team-invite">- <div><label for="invite-email-{{$account.ID}}">Email</label><input type="email" id="invite-email-{{$account.ID}}" placeholder="[email protected]" autocomplete="off"></div>- <div><label for="invite-role-{{$account.ID}}">Role</label><select id="invite-role-{{$account.ID}}"><option value="admin">Admin</option><option value="tech">Tech</option><option value="read_only">Read-only</option></select></div>- <button type="button" class="btn-primary" style="padding:8px 14px;font-size:13px" data-action="invite-member" data-account-id="{{$account.ID}}">Invite</button>- </div>- </div>-- {{if eq $account.Kind "msp"}}- <div class="add-workspace-form" id="add-ws-form-{{$account.ID}}">- <label for="ws-name-{{$account.ID}}">Workspace name (e.g. client name)</label>- <input type="text" id="ws-name-{{$account.ID}}" placeholder="Acme Corp" maxlength="80" autocomplete="off">- <div class="form-actions">- <button type="button" class="btn-primary" data-action="create-workspace" data-account-id="{{$account.ID}}">Create workspace</button>- <button type="button" class="btn-secondary" data-action="toggle-add-workspace" data-account-id="{{$account.ID}}">Cancel</button>- <div class="spinner" id="ws-spinner-{{$account.ID}}"></div>- </div>- </div>- {{end}}- {{end}}- </section>- {{end}}- {{end}}- </div>-- <section class="service-section">- <div class="service-header">- <h2>Other account services</h2>- <div class="service-note">Self-hosted commercial account actions now live here. The public utility pages remain as compatibility entry points, not the primary account surface.</div>- </div>- <div class="service-grid">- <button class="service-card service-card-button" type="button" id="open-manage-service" data-account-service-action="open-service-panel" data-account-service-panel="manage-service-panel" data-account-service-focus="manage-inline-email">- <h3>Manage subscriptions</h3>- <p>Open Stripe billing access for existing self-hosted subscriptions without leaving the Pulse Account shell.</p>- </button>- <button class="service-card service-card-button" type="button" id="open-retrieve-service" data-account-service-action="open-service-panel" data-account-service-panel="retrieve-service-panel" data-account-service-focus="retrieve-inline-email">- <h3>Retrieve licenses</h3>- <p>Recover the latest active self-hosted license and invoice link for a commercial email address.</p>- </button>- <button class="service-card service-card-button" type="button" id="open-refund-service" data-account-service-action="open-service-panel" data-account-service-panel="refund-service-panel" data-account-service-focus="refund-inline-email">- <h3>Refund requests</h3>- <p>Request an immediate self-serve refund for eligible self-hosted purchases with explicit revocation confirmation.</p>- </button>- <button class="service-card service-card-button" type="button" id="open-data-service" data-account-service-action="open-service-panel" data-account-service-panel="data-service-panel" data-account-service-focus="data-export-email">- <h3>Data and privacy</h3>- <p>Request commercial data export or deletion without leaving the account shell.</p>- </button>- </div>-- <div class="service-panel" id="manage-service-panel">- <div id="manage-service-root">- <h3>Manage subscriptions</h3>- <p>Request a verification code for the commercial email, then open the Stripe customer portal for billing changes, invoices, and subscription actions.</p>- <div id="manage-inline-step1">- <div class="form-group">- <label for="manage-inline-email">Email address</label>- <input type="email" id="manage-inline-email" value="{{.Email}}" autocomplete="email">- </div>- <div class="form-actions">- <button class="btn-primary" type="button" id="manage-inline-request" data-account-service-action="manage-inline-request">Send Verification Code</button>- </div>- </div>- <div id="manage-inline-step2" style="display:none">- <div class="form-group">- <label for="manage-inline-code">Verification code</label>- <input type="text" id="manage-inline-code" inputmode="numeric" pattern="[0-9]{6}" placeholder="123456">- </div>- <div class="form-actions">- <button class="btn-primary" type="button" id="manage-inline-confirm" data-account-service-action="manage-inline-confirm">Open Customer Portal</button>- </div>- <div class="helper-text">Need a new code? <a href="#" id="manage-inline-resend" data-account-service-action="manage-inline-resend">Send again</a></div>- </div>- <div class="service-status" id="manage-inline-status"></div>- </div>- </div>-- <div class="service-panel" id="retrieve-service-panel">- <div id="retrieve-service-root">- <h3>Retrieve licenses</h3>- <p>Request a verification code for the commercial email, then reveal the current active self-hosted license without leaving Pulse Account.</p>- <div id="retrieve-inline-step1">- <div class="form-group">- <label for="retrieve-inline-email">Email address</label>- <input type="email" id="retrieve-inline-email" value="{{.Email}}" autocomplete="email">- </div>- <div class="form-actions">- <button class="btn-primary" type="button" id="retrieve-inline-request" data-account-service-action="retrieve-inline-request">Send Verification Code</button>- </div>- </div>- <div id="retrieve-inline-step2" style="display:none">- <div class="form-group">- <label for="retrieve-inline-code">Verification code</label>- <input type="text" id="retrieve-inline-code" inputmode="numeric" pattern="[0-9]{6}" placeholder="123456">- </div>- <div class="form-actions">- <button class="btn-primary" type="button" id="retrieve-inline-confirm" data-account-service-action="retrieve-inline-confirm">Show License</button>- <button class="btn-secondary" type="button" id="retrieve-inline-copy" data-account-service-action="retrieve-inline-copy" style="display:none">Copy License Key</button>- <a class="btn-secondary" id="retrieve-inline-invoice" href="#" target="_blank" rel="noopener" style="display:none">View Invoice</a>- </div>- <div class="helper-text">Use the latest active self-hosted license for this commercial email.</div>- </div>- <div class="service-status" id="retrieve-inline-status"></div>- <div id="retrieve-inline-result" style="display:none; margin-top:14px">- <label for="retrieve-inline-token">License key</label>- <textarea id="retrieve-inline-token" readonly></textarea>- <div class="result-grid">- <div>- <div class="result-meta-label">Plan</div>- <div class="result-meta-value" id="retrieve-inline-tier"></div>- </div>- <div>- <div class="result-meta-label">Issued</div>- <div class="result-meta-value" id="retrieve-inline-issued"></div>- </div>- <div>- <div class="result-meta-label">Expires</div>- <div class="result-meta-value" id="retrieve-inline-expires"></div>- </div>- <div>- <div class="result-meta-label">Purchase Email</div>- <div class="result-meta-value" id="retrieve-inline-email-value"></div>- </div>- </div>- </div>- </div>- </div>-- <div class="service-panel" id="refund-service-panel">- <div id="refund-service-root">- <h3>Refund requests</h3>- <p>Process an eligible self-serve refund for a self-hosted purchase. This revokes the associated license immediately.</p>- <div class="warning">- <strong>Warning:</strong> completing a refund immediately revokes the affected license. This should only be used when the refund window and commercial contract allow it.- </div>- <div class="form-group">- <label for="refund-inline-email">Email address</label>- <input type="email" id="refund-inline-email" value="{{.Email}}" autocomplete="email">- </div>- <div class="form-group">- <label for="refund-inline-token">License key</label>- <input type="text" id="refund-inline-token" placeholder="pulse_xxxxx">- </div>- <div class="form-actions">- <button class="btn-danger" type="button" id="refund-inline-submit" data-account-service-action="refund-inline-submit">Process Refund</button>- </div>- <div class="helper-text">If this purchase is not eligible for self-serve refund, use the public support path instead: <a href="{{.PublicSiteURL}}/refund.html?email={{.Email}}">open refund support page</a>.</div>- <div class="service-status" id="refund-inline-status"></div>- </div>- </div>-- <div class="service-panel" id="data-service-panel">- <h3>Data and privacy</h3>- <p>Request export or deletion of the commercial data tied to an email address. Payment data held directly by Stripe still requires support handling.</p>-- <div class="subsection">- <div id="data-export-root">- <h4>Export My Data</h4>- <div id="data-export-step1">- <div class="form-group">- <label for="data-export-email">Email address</label>- <input type="email" id="data-export-email" value="{{.Email}}" autocomplete="email">- </div>- <div class="form-actions">- <button class="btn-primary" type="button" id="data-export-request" data-account-service-action="data-export-request">Send Verification Code</button>- </div>- </div>- <div id="data-export-step2" style="display:none">- <div class="form-group">- <label for="data-export-code">Verification code</label>- <input type="text" id="data-export-code" inputmode="numeric" pattern="[0-9]{6}" placeholder="123456">- </div>- <div class="form-actions">- <button class="btn-primary" type="button" id="data-export-confirm" data-account-service-action="data-export-confirm">Export My Data</button>- </div>- <div class="helper-text">Need a new code? <a href="#" id="data-export-resend" data-account-service-action="data-export-resend">Send again</a></div>- </div>- <div class="service-status" id="data-export-status"></div>- <div id="data-export-result" style="display:none; margin-top:14px">- <label for="data-export-payload">Export payload</label>- <textarea id="data-export-payload" readonly></textarea>- </div>- </div>- </div>-- <div class="subsection">- <div id="data-delete-root">- <h4>Delete My Data</h4>- <div class="warning">- <strong>Warning:</strong> deleting commercial data also revokes license records and cannot be undone.- </div>- <div id="data-delete-step1">- <div class="form-group">- <label for="data-delete-email">Email address</label>- <input type="email" id="data-delete-email" value="{{.Email}}" autocomplete="email">- </div>- <div class="form-actions">- <button class="btn-danger" type="button" id="data-delete-request" data-account-service-action="data-delete-request">Send Verification Code</button>- </div>- </div>- <div id="data-delete-step2" style="display:none">- <div class="form-group">- <label for="data-delete-code">Verification code</label>- <input type="text" id="data-delete-code" inputmode="numeric" pattern="[0-9]{6}" placeholder="123456">- </div>- <div class="checkbox-row">- <input type="checkbox" id="data-delete-confirm-check">- <span>I understand this permanently deletes my commercial data and revokes associated licenses.</span>- </div>- <div class="form-actions">- <button class="btn-danger" type="button" id="data-delete-confirm" data-account-service-action="data-delete-confirm">Delete My Data</button>- </div>- <div class="helper-text">Need a new code? <a href="#" id="data-delete-resend" data-account-service-action="data-delete-resend">Send again</a></div>- </div>- <div class="service-status" id="data-delete-status"></div>- </div>- </div>- <div class="helper-text">Payment-card data stays with Stripe. For Stripe deletion support, contact <a href="mailto:{{.SupportEmail}}">{{.SupportEmail}}</a>.</div>- </div>- </section>+ <div id="portal-app-root"></div></main><div class="toast" id="toast"></div>diff --git a/internal/cloudcp/routes_auth_test.go b/internal/cloudcp/routes_auth_test.goindex b9ffe00ee2..e10353cc78 100644--- a/internal/cloudcp/routes_auth_test.go+++ b/internal/cloudcp/routes_auth_test.go@@ -408,8 +408,16 @@ func TestRegisterRoutes_PortalPageSessionModes(t *testing.T) {if unauthRec.Code != http.StatusOK {t.Fatalf("unauth status = %d, want %d (body=%q)", unauthRec.Code, http.StatusOK, unauthRec.Body.String())}- if !strings.Contains(unauthRec.Body.String(), "Sign in to manage Cloud workspaces, MSP access, and commercial account services.") {- t.Fatalf("expected login shell in unauthenticated portal page, body=%q", unauthRec.Body.String())+ for _, needle := range []string{+ `id="portal-app-root"`,+ `"authenticated":false`,+ `"magic_link_request_path":"` + portal.PortalMagicLinkRequestPath + `"`,+ `"signup_path":"` + portal.PortalSignupPath + `"`,+ "Enter the commercial email address for your Pulse account.",+ } {+ if !strings.Contains(unauthRec.Body.String(), needle) {+ t.Fatalf("expected unauthenticated portal page to contain %q, body=%q", needle, unauthRec.Body.String())+ }}authReq := httptest.NewRequest(http.MethodGet, portal.PortalPagePath, nil)@@ -423,6 +431,8 @@ func TestRegisterRoutes_PortalPageSessionModes(t *testing.T) {"Pulse Account","Acme MSP",`id="pulse-account-bootstrap"`,+ `id="portal-app-root"`,+ `"authenticated":true`,"Other account services","self-hosted billing, license recovery, refund, and privacy tools below now share the same Pulse Account shell",} {