diff --git a/site/src/pages/settings/index.astro b/site/src/pages/settings/index.astro
index 677180b..54452b1 100644
--- a/site/src/pages/settings/index.astro
+++ b/site/src/pages/settings/index.astro
@@ -51,6 +51,25 @@ import Base from '../../layouts/Base.astro';
+
+
+ Email
+ Used to receive a reset link when you forget your password.
+
+
+
+
Password
@@ -602,10 +621,48 @@ import Base from '../../layouts/Base.astro';
}
});
+ // ── Email ─────────────────────────────────────────────────────────────────────
+
+ const emailForm = document.getElementById('email-form') as HTMLFormElement;
+ const emailInput = document.getElementById('email-input') as HTMLInputElement;
+ const emailStatus = document.getElementById('email-status') as HTMLElement;
+
+ async function loadEmail() {
+ const authUrl: string = (window as any).__bincioAuthUrl ?? '';
+ if (!authUrl) return; // single-user / no bincio-auth
+ try {
+ const r = await fetch(`${authUrl}/api/me/email`, { credentials: 'include' });
+ if (r.ok) {
+ const { email } = await r.json();
+ if (email) emailInput.value = email;
+ }
+ } catch { /* ignore */ }
+ }
+
+ emailForm.addEventListener('submit', async e => {
+ e.preventDefault();
+ const authUrl: string = (window as any).__bincioAuthUrl ?? '';
+ if (!authUrl) { setStatus(emailStatus, 'Not available on this instance.', false); return; }
+ const email = emailInput.value.trim();
+ try {
+ const r = await fetch(`${authUrl}/api/me/email`, {
+ method: 'POST',
+ credentials: 'include',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ email }),
+ });
+ const d = await r.json().catch(() => ({}));
+ setStatus(emailStatus, r.ok ? 'Saved.' : (d.detail ?? 'Failed.'), r.ok);
+ } catch {
+ setStatus(emailStatus, 'Could not reach server.', false);
+ }
+ });
+
// ── Init ─────────────────────────────────────────────────────────────────────
loadMe();
loadStorage();
+ loadEmail();
loadNavPrefs();
loadActivityDefaults();
loadStravaCreds();