aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/static/profile-page.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static/profile-page.js')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/profile-page.js24
1 files changed, 23 insertions, 1 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/profile-page.js b/packages/meshbay-hub/src/meshbay_hub/static/profile-page.js
index aac3c14..b52a8c6 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/profile-page.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/profile-page.js
@@ -370,6 +370,25 @@ export function ProfilePage({ user, onLogout }) {
}
}, [nodeKey, user.token]);
+ // Unlinking was only on the linked machine's own Node page, so an account
+ // whose node was on a machine since wiped or lost had no way out here; and a
+ // new machine's node will not take over a key that is still linked
+ // (main.js ensureNode). The hub accepts it from any session of the account.
+ const unlinkNodeKey = useCallback(async () => {
+ if (!await ask(t('settings.node_key_unlink_confirm'))) return;
+ setNodeKeyLoading(true);
+ setNodeKeyStatus('');
+ try {
+ await hubFetch('/v1/users/me/node_key', { method: 'DELETE', token: user.token });
+ setCurrentNodeKey(null);
+ setNodeKeyStatus(t('settings.node_key_unlinked'));
+ } catch (e) {
+ setNodeKeyStatus(e.message);
+ } finally {
+ setNodeKeyLoading(false);
+ }
+ }, [user.token]);
+
return html`
<div>
<h2>${t('profile.title')}</h2>
@@ -435,6 +454,9 @@ export function ProfilePage({ user, onLogout }) {
<div class="settings-row" style="margin-top:8px">
<span class="settings-label">${t('settings.node_key_current')}</span>
<code class="settings-value" style="font-size:0.8em;word-break:break-all">${currentNodeKey}</code>
+ <button class="admin-btn" onClick=${unlinkNodeKey} disabled=${nodeKeyLoading}>
+ ${t('settings.node_key_unlink')}
+ </button>
</div>
`}
<div style="display:flex;gap:8px;margin-top:10px;align-items:center">
@@ -448,7 +470,7 @@ export function ProfilePage({ user, onLogout }) {
</button>
</div>
${nodeKeyStatus && html`
- <p style="margin-top:6px;font-size:0.85em;color:${nodeKeyStatus === t('settings.node_key_success') ? 'var(--success)' : 'var(--error)'}">
+ <p style="margin-top:6px;font-size:0.85em;color:${[t('settings.node_key_success'), t('settings.node_key_unlinked')].includes(nodeKeyStatus) ? 'var(--success)' : 'var(--error)'}">
${nodeKeyStatus}
</p>
`}