Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
Settings: Delete my account asks the owner's proof
Duarte Santos34708011c4f1
diff --git a/frontend/src/components/DeleteAccount.jsx b/frontend/src/components/DeleteAccount.jsxindex 3fc9d5f20..2abc6664b 100644--- a/frontend/src/components/DeleteAccount.jsx+++ b/frontend/src/components/DeleteAccount.jsx@@ -1,65 +1,90 @@// Settings → Account → "Delete my account" (App Store rule 5.1.1(v): an app you can sign up in// lets you leave it from inside the app). The server removes the profile and everything in it// (POST /api/account/delete, the same clean-up as the admin's delete); the store then leaves this-// device where a sign-out does (useStore deleteAccount). The sheet offers the backup export first-// (the very one Data & backup has, handed in by Settings), and the account's name has to be typed-// back before the button does anything. Shown only while signed in to or paired with a server: a-// phone in local-only mode has no account, and "Reset everything" is how it wipes its data.+// device where a sign-out does (useStore deleteAccount). Two steps: the sheet offers the backup+// export first (the very one Data & backup has, handed in by Settings) and asks for the+// account's name typed back; then the owner's proof, the same step the other changes to a way in+// ask (ProveOwner): a passkey, or the current password where it counts. The proof carries the+// delete. Shown only while signed in to or paired with a server: a phone in local-only mode has+// no account, and "Reset everything" is how it wipes its data.import { useEffect, useRef, useState } from 'react'import { useStore } from '../store/useStore.js'import { useUI } from '../store/useUI.js'import { t } from '../lib/i18n.js'+import { api } from '../lib/api.js'+import { MOBILE } from '../lib/mobile.js'+import { passwordError, ProveOwner } from './PasswordAuth.jsx'import { Row, Button } from './ui.jsx'const errStyle = { color: 'var(--red)', marginTop: 10 }// The server's answer in the UI language, by its `code` (api/openapi.yaml, /api/account/delete).+// The proof's refusals (a wrong password, a passkey that did not verify, a pause) are worded the+// way the other proved changes word them; a passkey prompt that failed on this device says so.export function deleteAccountError(e) {switch (e?.data?.code) {case 'confirm-name': return t('That is not your account name.')case 'last-admin': return t('You’re the only admin here, and other profiles still use this server. Make someone else an admin first.')}+ if (e?.data?.code || e?.status === 429) return passwordError(e)+ if (e?.status == null && e?.name && e.name !== 'TypeError' && e.name !== 'Error') return t('Your passkey could not be confirmed.')return t('Couldn’t delete the account. Nothing was removed.')}export function DeleteAccountSheet({ close, exportBackup, exportBackupZip, hasMedia, done }) {const user = useStore(s => s.user)const [typed, setTyped] = useState('')- const [busy, setBusy] = useState(false)+ const [step, setStep] = useState('name') // 'name' | 'confirm'+ const [proofs, setProofs] = useState(null) // GET /api/account/passkeys: what can prove it is themconst [err, setErr] = useState(null)const ref = useRef(null)const name = user?.name || ''const match = !!name && typed.trim() === nameuseEffect(() => { setTimeout(() => ref.current?.focus(), 250) }, [])- const submit = async ev => {+ // Read as the sheet opens, so the proof step is ready by the time the name is typed.+ useEffect(() => { api('/api/account/passkeys').then(setProofs).catch(e => setErr(deleteAccountError(e))) }, [])+ const next = ev => {ev.preventDefault()- if (busy || !match) return- setBusy(true); setErr(null)- try { await useStore.getState().deleteAccount(typed.trim()) }- catch (e) { setErr(deleteAccountError(e)); setBusy(false); return }+ if (!match) return+ setStep('confirm')+ }+ const remove = async proof => {+ await useStore.getState().deleteAccount(typed.trim(), proof)close()useUI.getState().toast(t('Your account is gone. Thanks for every rep.'))done?.()}+ // The phone app cannot hold a passkey for your server (its own origin is not the server's), so+ // there only the password can say it is you.+ const passkey = !MOBILE && (proofs?.passkeys?.length || 0) > 0+ const password = !!proofs?.passwordreturn <><h3>{t('Delete your account?')}</h3><div className="muted small" style={{ marginBottom: 14, lineHeight: 1.5 }}>{t('Your profile, workouts, body weight, photos and videos are deleted from this server for good. There is no undo, and not even your admin can bring them back.')}</div>- <div className="small" style={{ marginBottom: 8 }}>{t('Want a copy first? Export a backup. You can import it into openGym anytime.')}</div>- {hasMedia && exportBackupZip- ? <Button icon="share" disabled={busy} onClick={exportBackupZip}>{t('Export with photos & videos (.zip)')}</Button>- : <Button icon="share" disabled={busy} onClick={exportBackup}>{t('Export backup (JSON)')}</Button>}- <form onSubmit={submit} noValidate style={{ marginTop: 18 }}>- <label className="small" htmlFor="delete-account-name" style={{ display: 'block', marginBottom: 6 }}>{t('Type {0} to confirm.', name)}</label>- <input ref={ref} id="delete-account-name" className="input" placeholder={t('Account name')} autoComplete="off"- autoCapitalize="none" autoCorrect="off" spellCheck={false} value={typed} onChange={e => { setTyped(e.target.value); setErr(null) }} />- {err && <div className="small" role="alert" style={errStyle}>{err}</div>}- <div style={{ height: 14 }} />- <button type="submit" className="btn danger" disabled={busy || !match}>{busy ? t('Deleting…') : t('Delete forever')}</button>- </form>- <div style={{ height: 8 }} />- <Button variant="ghost" className="dim" disabled={busy} onClick={close}>{t('Cancel')}</Button>+ {step === 'name' ? <>+ <div className="small" style={{ marginBottom: 8 }}>{t('Want a copy first? Export a backup. You can import it into openGym anytime.')}</div>+ {hasMedia && exportBackupZip+ ? <Button icon="share" onClick={exportBackupZip}>{t('Export with photos & videos (.zip)')}</Button>+ : <Button icon="share" onClick={exportBackup}>{t('Export backup (JSON)')}</Button>}+ <form onSubmit={next} noValidate style={{ marginTop: 18 }}>+ <label className="small" htmlFor="delete-account-name" style={{ display: 'block', marginBottom: 6 }}>{t('Type {0} to confirm.', name)}</label>+ <input ref={ref} id="delete-account-name" className="input" placeholder={t('Account name')} autoComplete="off"+ autoCapitalize="none" autoCorrect="off" spellCheck={false} value={typed} onChange={e => setTyped(e.target.value)} />+ <div style={{ height: 14 }} />+ <button type="submit" className="btn danger" disabled={!match}>{t('Continue')}</button>+ </form>+ <div style={{ height: 8 }} />+ <Button variant="ghost" className="dim" onClick={close}>{t('Cancel')}</Button>+ </> : <>+ <div className="dim small" style={{ marginBottom: 14 }}>{t('First confirm that it is you.')}</div>+ {!proofs ? (err ? <div className="small" role="alert" style={errStyle}>{err}</div> : <div className="dim small">{t('Loading…')}</div>)+ : MOBILE && !password ? <div className="dim small">{t('This app can’t confirm with a passkey. Delete your account from openGym in your browser, or add a password there first.')}</div>+ : <ProveOwner passkey={passkey} password={password} explain={deleteAccountError} danger submitText={t('Delete forever')} onProof={remove} />}+ <div style={{ height: 8 }} />+ <Button type="button" variant="ghost" className="dim" onClick={() => setStep('name')}>{t('Back')}</Button>+ </>}</>}diff --git a/frontend/src/components/DeleteAccount.test.jsx b/frontend/src/components/DeleteAccount.test.jsxindex ccaf0057a..bdfbebd9e 100644--- a/frontend/src/components/DeleteAccount.test.jsx+++ b/frontend/src/components/DeleteAccount.test.jsx@@ -6,20 +6,23 @@ import { DeleteAccountSheet, DeleteAccountRow, deleteAccountError } from './DeleglobalThis.IS_REACT_ACT_ENVIRONMENT = true-/* "Delete my account" on screen: the backup export is offered first, the button does nothing- until the account's name is typed back, and the server's refusals are said in the UI- language. The store is a stand-in; what the sheet asks of it and says back is the point. */+/* "Delete my account" on screen: the backup export is offered first, nothing goes on until the+ account's name is typed back, then the owner's proof (ProveOwner, the same step the other+ changes to a way in ask) carries the delete. The server's refusals are said in the UI+ language. The store and the API are stand-ins; what the sheet sends and says is the point. */const mocks = vi.hoisted(() => {- const state = { sheets: [] }+ const state = { sheets: [], MOBILE: false, webauthn: true, proofs: { passkeys: [{ id: 'k1' }], password: true } }state.toast = vi.fn()state.deleteAccount = vi.fn(async () => {})+ state.passkeyAssertion = vi.fn(async () => ({ cid: 'c1', credential: { id: 'k1' } }))+ state.api = vi.fn(async path => { if (path === '/api/account/passkeys') return state.proofs; return {} })state.snapshot = () => ({ user: { id: 'u1', name: 'Mallory' }, deleteAccount: state.deleteAccount })return state})vi.mock('../store/useStore.js', () => {const useStore = selector => selector ? selector(mocks.snapshot()) : mocks.snapshot()useStore.getState = mocks.snapshot- return { useStore }+ return { useStore, hasData: () => false }})vi.mock('../store/useUI.js', () => {const snap = () => ({ toast: (...a) => mocks.toast(...a), openSheet: (render, opts) => { mocks.sheets.push({ render, opts }); return {} } })@@ -27,6 +30,14 @@ vi.mock('../store/useUI.js', () => {useUI.getState = snapreturn { useUI }})+vi.mock('../lib/api.js', () => ({+ api: (...a) => mocks.api(...a),+ webauthnOK: () => mocks.webauthn,+ passkeyAssertion: (...a) => mocks.passkeyAssertion(...a),+ passwordLogin: vi.fn(), passwordRegister: vi.fn(), passwordResetRedeem: vi.fn(),+}))+vi.mock('../lib/mobile.js', () => ({ get MOBILE() { return mocks.MOBILE } }))+vi.mock('../sheets.jsx', () => ({ askAddDeviceData: vi.fn() }))const fail = (status, data) => Object.assign(new Error(data?.error || 'HTTP ' + status), { status, data })@@ -50,6 +61,13 @@ const button = (host, text) => [...host.querySelectorAll('button')].find(b => b.const submit = async host => { act(() => { host.querySelector('form').dispatchEvent(new Event('submit', { bubbles: true, cancelable: true })) }); await settle() }const alertText = host => host.querySelector('[role="alert"]')?.textContent || nullconst field = host => host.querySelector('input[placeholder="Account name"]')+const password = host => host.querySelector('input[placeholder="Current password"]')+// Past the name: typed, and "Continue".+async function toProof(host, name = 'Mallory') {+ await settle() // what can prove it, read as the sheet opens+ type(field(host), name)+ await submit(host)+}function sheet(props = {}) {const p = { close: vi.fn(), exportBackup: vi.fn(), exportBackupZip: vi.fn(), done: vi.fn(), hasMedia: false, ...props }@@ -57,6 +75,11 @@ function sheet(props = {}) {}beforeEach(() => {+ mocks.MOBILE = false+ mocks.webauthn = true+ mocks.proofs = { passkeys: [{ id: 'k1' }], password: true }+ mocks.api.mockClear()+ mocks.passkeyAssertion.mockClear()mocks.sheets.length = 0mocks.toast.mockClear()mocks.deleteAccount.mockReset()@@ -78,37 +101,78 @@ describe('DeleteAccountSheet', () => {expect(media.p.exportBackupZip).toHaveBeenCalledTimes(1)})- it('does nothing until the account name is typed back', async () => {+ it('goes nowhere until the account name is typed back', async () => {const { host } = sheet()+ await settle()expect(host.textContent).toContain('Type Mallory to confirm.')- expect(button(host, 'Delete forever').disabled).toBe(true)+ expect(button(host, 'Continue').disabled).toBe(true)type(field(host), 'mallory')- expect(button(host, 'Delete forever').disabled).toBe(true)+ expect(button(host, 'Continue').disabled).toBe(true)await submit(host)- expect(mocks.deleteAccount).not.toHaveBeenCalled()+ expect(host.textContent).not.toContain('First confirm that it is you.')type(field(host), 'Mallory ')- expect(button(host, 'Delete forever').disabled).toBe(false)+ expect(button(host, 'Continue').disabled).toBe(false)+ await submit(host)+ expect(host.textContent).toContain('First confirm that it is you.')+ expect(mocks.deleteAccount).not.toHaveBeenCalled() // the name alone deletes nothing})- it('deletes with the typed name, then closes, says goodbye and hands over to Settings', async () => {+ it('the passkey proves it and carries the delete; then it closes, says goodbye and hands over', async () => {const { p, host } = sheet()- type(field(host), ' Mallory')- await submit(host)- expect(mocks.deleteAccount).toHaveBeenCalledWith('Mallory')+ await toProof(host, ' Mallory')+ await act(async () => { button(host, 'Confirm with a passkey').click() })+ await settle()+ expect(mocks.passkeyAssertion).toHaveBeenCalled()+ expect(mocks.deleteAccount).toHaveBeenCalledWith('Mallory', { cid: 'c1', credential: { id: 'k1' } })expect(p.close).toHaveBeenCalled()expect(p.done).toHaveBeenCalled()expect(mocks.toast).toHaveBeenCalledWith('Your account is gone. Thanks for every rep.')})+ it('or the current password, where it counts', async () => {+ const { host } = sheet()+ await toProof(host)+ type(password(host), 'correct horse battery staple')+ await submit(host)+ expect(mocks.deleteAccount).toHaveBeenCalledWith('Mallory', { current: 'correct horse battery staple' })+ })++ it('a wrong password is said, and nothing is gone', async () => {+ mocks.deleteAccount.mockRejectedValue(fail(403, { error: 'your current password is not right', code: 'current-wrong' }))+ const { p, host } = sheet()+ await toProof(host)+ type(password(host), 'nope nope nope')+ await submit(host)+ expect(alertText(host)).toBe('Your current password is not right.')+ expect(p.close).not.toHaveBeenCalled()+ expect(p.done).not.toHaveBeenCalled()+ })+it('the last admin hears why, and the sheet stays open', async () => {mocks.deleteAccount.mockRejectedValue(fail(409, { error: 'the last admin cannot leave while other profiles remain', code: 'last-admin' }))const { p, host } = sheet()- type(field(host), 'Mallory')+ await toProof(host)+ type(password(host), 'correct horse battery staple')await submit(host)expect(alertText(host)).toBe('You’re the only admin here, and other profiles still use this server. Make someone else an admin first.')expect(p.close).not.toHaveBeenCalled()- expect(p.done).not.toHaveBeenCalled()- expect(button(host, 'Delete forever').disabled).toBe(false) // not stuck on "Deleting…"+ })++ it('the phone app offers no passkey, which it cannot hold for the server, only the password', async () => {+ mocks.MOBILE = true+ const { host } = sheet()+ await toProof(host)+ expect(button(host, 'Confirm with a passkey')).toBeUndefined()+ expect(password(host)).toBeTruthy()+ })++ it('a phone with no password to prove it says where to do it instead', async () => {+ mocks.MOBILE = true+ mocks.proofs = { passkeys: [{ id: 'k1' }], password: false }+ const { host } = sheet()+ await toProof(host)+ expect(host.textContent).toContain('This app can’t confirm with a passkey. Delete your account from openGym in your browser, or add a password there first.')+ expect(password(host)).toBeNull()})})@@ -116,6 +180,9 @@ describe('deleteAccountError', () => {it('words each refusal, and anything else as nothing removed', () => {expect(deleteAccountError(fail(400, { code: 'confirm-name' }))).toBe('That is not your account name.')expect(deleteAccountError(fail(409, { code: 'last-admin' }))).toMatch(/only admin/)+ expect(deleteAccountError(fail(403, { code: 'passkey' }))).toBe('Your passkey could not be confirmed.')+ expect(deleteAccountError(Object.assign(new Error('x'), { name: 'SecurityError' }))).toBe('Your passkey could not be confirmed.')+ expect(deleteAccountError(fail(500, {}))).toBe('Couldn’t delete the account. Nothing was removed.')expect(deleteAccountError(new TypeError('Failed to fetch'))).toBe('Couldn’t delete the account. Nothing was removed.')})})diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.jsindex 5fbcd44da..a946b1768 100644--- a/frontend/src/locales/ar.js+++ b/frontend/src/locales/ar.js@@ -2305,10 +2305,10 @@ export default {'Want a copy first? Export a backup. You can import it into openGym anytime.': 'تريد نسخة أولًا؟ صدّر نسخة احتياطية. يمكنك استيرادها إلى openGym في أي وقت.','Type {0} to confirm.': 'اكتب {0} للتأكيد.','Account name': 'اسم الحساب',- 'Deleting…': 'جارٍ الحذف…','Delete forever': 'حذف نهائي','That is not your account name.': 'هذا ليس اسم حسابك.','You’re the only admin here, and other profiles still use this server. Make someone else an admin first.': 'أنت المسؤول الوحيد هنا، وملفات أخرى ما زالت تستخدم هذا الخادم. اجعل شخصًا آخر مسؤولًا أولًا.','Couldn’t delete the account. Nothing was removed.': 'تعذّر حذف الحساب. لم يُحذف أي شيء.','Your account is gone. Thanks for every rep.': 'حسابك لم يعد موجودًا. شكرًا على كل تكرار.',+ 'This app can’t confirm with a passkey. Delete your account from openGym in your browser, or add a password there first.': 'لا يستطيع هذا التطبيق التأكيد بمفتاح مرور. احذف حسابك من openGym في المتصفح، أو أضف كلمة مرور هناك أولًا.',}diff --git a/frontend/src/locales/bn.js b/frontend/src/locales/bn.jsindex 03023a70d..cc124ba8e 100644--- a/frontend/src/locales/bn.js+++ b/frontend/src/locales/bn.js@@ -2329,10 +2329,10 @@ export default {'Want a copy first? Export a backup. You can import it into openGym anytime.': 'আগে একটা কপি চান? একটি ব্যাকআপ এক্সপোর্ট করুন। যেকোনো সময় openGym-এ ইমপোর্ট করতে পারবেন।','Type {0} to confirm.': 'নিশ্চিত করতে {0} লিখুন।','Account name': 'অ্যাকাউন্টের নাম',- 'Deleting…': 'মোছা হচ্ছে…','Delete forever': 'চিরতরে মুছুন','That is not your account name.': 'এটি আপনার অ্যাকাউন্টের নাম নয়।','You’re the only admin here, and other profiles still use this server. Make someone else an admin first.': 'আপনি এখানে একমাত্র অ্যাডমিন, আর অন্য প্রোফাইলগুলো এখনও এই সার্ভার ব্যবহার করছে। আগে অন্য কাউকে অ্যাডমিন করুন।','Couldn’t delete the account. Nothing was removed.': 'অ্যাকাউন্ট মোছা যায়নি। কিছুই সরানো হয়নি।','Your account is gone. Thanks for every rep.': 'আপনার অ্যাকাউন্ট মুছে গেছে। প্রতিটি রেপের জন্য ধন্যবাদ।',+ 'This app can’t confirm with a passkey. Delete your account from openGym in your browser, or add a password there first.': 'এই অ্যাপ পাসকি দিয়ে নিশ্চিত করতে পারে না। ব্রাউজারে openGym থেকে আপনার অ্যাকাউন্ট মুছুন, অথবা আগে সেখানে একটি পাসওয়ার্ড যোগ করুন।',}diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex 971517908..4413e3c65 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -2270,10 +2270,10 @@ export default {'Want a copy first? Export a backup. You can import it into openGym anytime.': 'Lieber erst eine Kopie? Exportiere ein Backup. Du kannst es jederzeit wieder in openGym importieren.','Type {0} to confirm.': 'Gib {0} ein, um zu bestätigen.','Account name': 'Kontoname',- 'Deleting…': 'Wird gelöscht…','Delete forever': 'Endgültig löschen','That is not your account name.': 'Das ist nicht dein Kontoname.','You’re the only admin here, and other profiles still use this server. Make someone else an admin first.': 'Du bist hier der einzige Admin, und andere Profile nutzen diesen Server noch. Mach zuerst jemand anderen zum Admin.','Couldn’t delete the account. Nothing was removed.': 'Das Konto konnte nicht gelöscht werden. Es wurde nichts entfernt.','Your account is gone. Thanks for every rep.': 'Dein Konto ist weg. Danke für jede Wiederholung.',+ 'This app can’t confirm with a passkey. Delete your account from openGym in your browser, or add a password there first.': 'Diese App kann nicht mit einem Passkey bestätigen. Lösch dein Konto in openGym im Browser, oder leg dort zuerst ein Passwort fest.',}diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.jsindex ea7b14c4e..c28d4e6d7 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -2250,10 +2250,10 @@ export default {'Want a copy first? Export a backup. You can import it into openGym anytime.': '¿Quieres una copia antes? Exporta una copia de seguridad. Puedes importarla en openGym cuando quieras.','Type {0} to confirm.': 'Escribe {0} para confirmar.','Account name': 'Nombre de la cuenta',- 'Deleting…': 'Eliminando…','Delete forever': 'Eliminar para siempre','That is not your account name.': 'Ese no es el nombre de tu cuenta.','You’re the only admin here, and other profiles still use this server. Make someone else an admin first.': 'Eres el único administrador aquí y otros perfiles siguen usando este servidor. Haz administrador a otra persona primero.','Couldn’t delete the account. Nothing was removed.': 'No se pudo eliminar la cuenta. No se borró nada.','Your account is gone. Thanks for every rep.': 'Tu cuenta ya no existe. Gracias por cada repetición.',+ 'This app can’t confirm with a passkey. Delete your account from openGym in your browser, or add a password there first.': 'Esta app no puede confirmar con una passkey. Elimina tu cuenta desde openGym en tu navegador, o añade allí una contraseña primero.',}diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex 5a40e1099..d940b4400 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -2250,10 +2250,10 @@ export default {'Want a copy first? Export a backup. You can import it into openGym anytime.': 'Une copie d’abord ? Exporte une sauvegarde. Tu pourras l’importer dans openGym quand tu veux.','Type {0} to confirm.': 'Tape {0} pour confirmer.','Account name': 'Nom du compte',- 'Deleting…': 'Suppression…','Delete forever': 'Supprimer pour de bon','That is not your account name.': 'Ce n’est pas le nom de ton compte.','You’re the only admin here, and other profiles still use this server. Make someone else an admin first.': 'Tu es le seul admin ici, et d’autres profils utilisent encore ce serveur. Nomme d’abord quelqu’un d’autre admin.','Couldn’t delete the account. Nothing was removed.': 'Impossible de supprimer le compte. Rien n’a été effacé.','Your account is gone. Thanks for every rep.': 'Ton compte n’existe plus. Merci pour chaque répétition.',+ 'This app can’t confirm with a passkey. Delete your account from openGym in your browser, or add a password there first.': 'Cette app ne peut pas confirmer avec une passkey. Supprime ton compte depuis openGym dans ton navigateur, ou ajoute d’abord un mot de passe là-bas.',}diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.jsindex fc8be6c73..af2a6f6ab 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -2250,10 +2250,10 @@ export default {'Want a copy first? Export a backup. You can import it into openGym anytime.': 'पहले एक कॉपी चाहिए? बैकअप निर्यात करें। आप उसे कभी भी openGym में आयात कर सकते हैं।','Type {0} to confirm.': 'पुष्टि के लिए {0} लिखें।','Account name': 'खाते का नाम',- 'Deleting…': 'हटाया जा रहा है…','Delete forever': 'हमेशा के लिए हटाएँ','That is not your account name.': 'यह आपके खाते का नाम नहीं है।','You’re the only admin here, and other profiles still use this server. Make someone else an admin first.': 'आप यहाँ के अकेले एडमिन हैं, और दूसरी प्रोफ़ाइलें अभी भी यह सर्वर इस्तेमाल करती हैं। पहले किसी और को एडमिन बनाएँ।','Couldn’t delete the account. Nothing was removed.': 'खाता हटाया नहीं जा सका। कुछ भी नहीं हटाया गया।','Your account is gone. Thanks for every rep.': 'आपका खाता हट गया। हर रेप के लिए धन्यवाद।',+ 'This app can’t confirm with a passkey. Delete your account from openGym in your browser, or add a password there first.': 'यह ऐप पासकी से पुष्टि नहीं कर सकता। ब्राउज़र में openGym से अपना खाता हटाएँ, या पहले वहाँ एक पासवर्ड जोड़ें।',}diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.jsindex 5342fae8e..c8fb6b2f1 100644--- a/frontend/src/locales/hu.js+++ b/frontend/src/locales/hu.js@@ -2253,10 +2253,10 @@ export default {'Want a copy first? Export a backup. You can import it into openGym anytime.': 'Előbb egy másolat? Exportálj egy biztonsági mentést. Bármikor visszaimportálhatod az openGymbe.','Type {0} to confirm.': 'A megerősítéshez írd be: {0}','Account name': 'Fiók neve',- 'Deleting…': 'Törlés…','Delete forever': 'Végleges törlés','That is not your account name.': 'Ez nem a fiókod neve.','You’re the only admin here, and other profiles still use this server. Make someone else an admin first.': 'Te vagy itt az egyetlen admin, és más profilok még használják ezt a szervert. Előbb tegyél meg valaki mást adminnak.','Couldn’t delete the account. Nothing was removed.': 'Nem sikerült törölni a fiókot. Semmi sem lett eltávolítva.','Your account is gone. Thanks for every rep.': 'A fiókod eltűnt. Köszönjük az összes ismétlést.',+ 'This app can’t confirm with a passkey. Delete your account from openGym in your browser, or add a password there first.': 'Ez az app nem tud jelszókulccsal megerősíteni. Töröld a fiókod az openGymben a böngészőből, vagy előbb adj meg ott egy jelszót.',}diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex 0102eadfa..d754cdf68 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -2250,10 +2250,10 @@ export default {'Want a copy first? Export a backup. You can import it into openGym anytime.': 'Prima una copia? Esporta un backup. Puoi importarlo in openGym quando vuoi.','Type {0} to confirm.': 'Scrivi {0} per confermare.','Account name': 'Nome dell’account',- 'Deleting…': 'Eliminazione…','Delete forever': 'Elimina per sempre','That is not your account name.': 'Questo non è il nome del tuo account.','You’re the only admin here, and other profiles still use this server. Make someone else an admin first.': 'Sei l’unico admin qui e altri profili usano ancora questo server. Prima nomina admin qualcun altro.','Couldn’t delete the account. Nothing was removed.': 'Impossibile eliminare l’account. Non è stato rimosso nulla.','Your account is gone. Thanks for every rep.': 'Il tuo account non c’è più. Grazie per ogni ripetizione.',+ 'This app can’t confirm with a passkey. Delete your account from openGym in your browser, or add a password there first.': 'Questa app non può confermare con una passkey. Elimina l’account da openGym nel browser, oppure aggiungi prima lì una password.',}diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.jsindex 848dca9af..cfa26175b 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -2250,10 +2250,10 @@ export default {'Want a copy first? Export a backup. You can import it into openGym anytime.': '먼저 사본을 받아 둘까요? 백업을 내보내세요. 언제든 openGym으로 다시 가져올 수 있어요.','Type {0} to confirm.': '확인하려면 {0}을(를) 입력하세요.','Account name': '계정 이름',- 'Deleting…': '삭제 중…','Delete forever': '영구 삭제','That is not your account name.': '계정 이름이 맞지 않아요.','You’re the only admin here, and other profiles still use this server. Make someone else an admin first.': '이 서버의 유일한 관리자인데 다른 프로필이 아직 사용 중이에요. 먼저 다른 사람을 관리자로 지정하세요.','Couldn’t delete the account. Nothing was removed.': '계정을 삭제하지 못했어요. 아무것도 지워지지 않았어요.','Your account is gone. Thanks for every rep.': '계정이 삭제됐어요. 모든 반복에 감사해요.',+ 'This app can’t confirm with a passkey. Delete your account from openGym in your browser, or add a password there first.': '이 앱에서는 패스키로 확인할 수 없어요. 브라우저의 openGym에서 계정을 삭제하거나, 먼저 그곳에서 비밀번호를 추가하세요.',}diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.jsindex 3ef5273c6..570b6b97e 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -2250,10 +2250,10 @@ export default {'Want a copy first? Export a backup. You can import it into openGym anytime.': 'Najpierw kopia? Wyeksportuj kopię zapasową. Możesz ją zaimportować do openGym w każdej chwili.','Type {0} to confirm.': 'Wpisz {0}, aby potwierdzić.','Account name': 'Nazwa konta',- 'Deleting…': 'Usuwanie…','Delete forever': 'Usuń na zawsze','That is not your account name.': 'To nie jest nazwa Twojego konta.','You’re the only admin here, and other profiles still use this server. Make someone else an admin first.': 'Jesteś tu jedynym administratorem, a inne profile wciąż korzystają z tego serwera. Najpierw zrób administratorem kogoś innego.','Couldn’t delete the account. Nothing was removed.': 'Nie udało się usunąć konta. Nic nie zostało usunięte.','Your account is gone. Thanks for every rep.': 'Twojego konta już nie ma. Dzięki za każde powtórzenie.',+ 'This app can’t confirm with a passkey. Delete your account from openGym in your browser, or add a password there first.': 'Ta aplikacja nie może potwierdzić kluczem dostępu. Usuń konto w openGym w przeglądarce albo najpierw ustaw tam hasło.',}diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.jsindex 8091af717..c7816509d 100644--- a/frontend/src/locales/pt-BR.js+++ b/frontend/src/locales/pt-BR.js@@ -1410,12 +1410,12 @@ export const PT_BR_OVERRIDES = {'Your profile, workouts, body weight, photos and videos are deleted from this server for good. There is no undo, and not even your admin can bring them back.': 'Seu perfil, treinos, peso corporal, fotos e vídeos são apagados deste servidor para sempre. Não tem volta, nem seu administrador consegue recuperá-los.','Want a copy first? Export a backup. You can import it into openGym anytime.': 'Quer uma cópia antes? Exporte um backup. Você pode importá-lo no openGym quando quiser.','Type {0} to confirm.': 'Digite {0} para confirmar.',- 'Deleting…': 'Excluindo…','Delete forever': 'Excluir para sempre','That is not your account name.': 'Esse não é o nome da sua conta.','You’re the only admin here, and other profiles still use this server. Make someone else an admin first.': 'Você é o único administrador aqui e outros perfis ainda usam este servidor. Torne outra pessoa administradora primeiro.','Couldn’t delete the account. Nothing was removed.': 'Não foi possível excluir a conta. Nada foi removido.','Your account is gone. Thanks for every rep.': 'Sua conta não existe mais. Obrigado por cada repetição.',+ 'This app can’t confirm with a passkey. Delete your account from openGym in your browser, or add a password there first.': 'Este aplicativo não consegue confirmar com uma chave de acesso. Exclua sua conta no openGym pelo navegador, ou adicione uma senha lá primeiro.',}export default { ...pt, ...PT_BR_OVERRIDES }diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex 83d200623..d5e398a31 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -2250,10 +2250,10 @@ export default {'Want a copy first? Export a backup. You can import it into openGym anytime.': 'Queres uma cópia primeiro? Exporta uma cópia de segurança. Podes importá-la no openGym quando quiseres.','Type {0} to confirm.': 'Escreve {0} para confirmar.','Account name': 'Nome da conta',- 'Deleting…': 'A eliminar…','Delete forever': 'Eliminar para sempre','That is not your account name.': 'Esse não é o nome da tua conta.','You’re the only admin here, and other profiles still use this server. Make someone else an admin first.': 'És o único administrador aqui e outros perfis ainda usam este servidor. Torna outra pessoa administradora primeiro.','Couldn’t delete the account. Nothing was removed.': 'Não foi possível eliminar a conta. Nada foi removido.','Your account is gone. Thanks for every rep.': 'A tua conta já não existe. Obrigado por cada repetição.',+ 'This app can’t confirm with a passkey. Delete your account from openGym in your browser, or add a password there first.': 'Esta app não consegue confirmar com uma passkey. Elimina a tua conta no openGym pelo navegador, ou adiciona lá uma palavra-passe primeiro.',}diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex 76a136b19..92ca31702 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -2254,10 +2254,10 @@ export default {'Want a copy first? Export a backup. You can import it into openGym anytime.': 'Сначала копию? Экспортируйте резервную копию. Её можно импортировать в openGym в любой момент.','Type {0} to confirm.': 'Введите {0} для подтверждения.','Account name': 'Имя аккаунта',- 'Deleting…': 'Удаление…','Delete forever': 'Удалить навсегда','That is not your account name.': 'Это не имя вашего аккаунта.','You’re the only admin here, and other profiles still use this server. Make someone else an admin first.': 'Вы здесь единственный администратор, а другие профили ещё пользуются этим сервером. Сначала назначьте администратором кого-то другого.','Couldn’t delete the account. Nothing was removed.': 'Не удалось удалить аккаунт. Ничего не удалено.','Your account is gone. Thanks for every rep.': 'Ваш аккаунт удалён. Спасибо за каждое повторение.',+ 'This app can’t confirm with a passkey. Delete your account from openGym in your browser, or add a password there first.': 'Это приложение не может подтвердить ключом доступа. Удалите аккаунт в openGym через браузер или сначала задайте там пароль.',}diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.jsindex 121849fe0..9b3a48e18 100644--- a/frontend/src/locales/th.js+++ b/frontend/src/locales/th.js@@ -2261,10 +2261,10 @@ export default {'Want a copy first? Export a backup. You can import it into openGym anytime.': 'อยากเก็บสำเนาไว้ก่อนไหม ส่งออกข้อมูลสำรองได้เลย แล้วนำเข้า openGym ได้ทุกเมื่อ','Type {0} to confirm.': 'พิมพ์ {0} เพื่อยืนยัน','Account name': 'ชื่อบัญชี',- 'Deleting…': 'กำลังลบ…','Delete forever': 'ลบถาวร','That is not your account name.': 'นี่ไม่ใช่ชื่อบัญชีของคุณ','You’re the only admin here, and other profiles still use this server. Make someone else an admin first.': 'คุณเป็นผู้ดูแลระบบคนเดียวที่นี่ และยังมีโปรไฟล์อื่นใช้เซิร์ฟเวอร์นี้อยู่ ตั้งคนอื่นเป็นผู้ดูแลระบบก่อน','Couldn’t delete the account. Nothing was removed.': 'ลบบัญชีไม่สำเร็จ ไม่มีอะไรถูกลบ','Your account is gone. Thanks for every rep.': 'บัญชีของคุณถูกลบแล้ว ขอบคุณสำหรับทุกเรป',+ 'This app can’t confirm with a passkey. Delete your account from openGym in your browser, or add a password there first.': 'แอปนี้ยืนยันด้วยพาสคีย์ไม่ได้ ลบบัญชีจาก openGym ในเบราว์เซอร์ หรือเพิ่มรหัสผ่านที่นั่นก่อน',}diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex e949cf915..f2c85700c 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -2250,10 +2250,10 @@ export default {'Want a copy first? Export a backup. You can import it into openGym anytime.': 'Önce bir kopya mı? Bir yedek dışa aktar. İstediğin zaman openGym’e geri aktarabilirsin.','Type {0} to confirm.': 'Onaylamak için {0} yaz.','Account name': 'Hesap adı',- 'Deleting…': 'Siliniyor…','Delete forever': 'Kalıcı olarak sil','That is not your account name.': 'Bu senin hesap adın değil.','You’re the only admin here, and other profiles still use this server. Make someone else an admin first.': 'Buradaki tek yönetici sensin ve başka profiller bu sunucuyu hâlâ kullanıyor. Önce başka birini yönetici yap.','Couldn’t delete the account. Nothing was removed.': 'Hesap silinemedi. Hiçbir şey kaldırılmadı.','Your account is gone. Thanks for every rep.': 'Hesabın silindi. Her tekrar için teşekkürler.',+ 'This app can’t confirm with a passkey. Delete your account from openGym in your browser, or add a password there first.': 'Bu uygulama geçiş anahtarıyla onaylayamaz. Hesabını tarayıcıda openGym’den sil ya da önce orada bir parola ekle.',}diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.jsindex 585a9455b..638bf0b26 100644--- a/frontend/src/locales/uk.js+++ b/frontend/src/locales/uk.js@@ -2247,10 +2247,10 @@ export default {'Want a copy first? Export a backup. You can import it into openGym anytime.': 'Спершу копію? Експортуйте резервну копію. Її можна імпортувати в openGym будь-коли.','Type {0} to confirm.': 'Введіть {0} для підтвердження.','Account name': 'Назва акаунта',- 'Deleting…': 'Видалення…','Delete forever': 'Видалити назавжди','That is not your account name.': 'Це не назва вашого акаунта.','You’re the only admin here, and other profiles still use this server. Make someone else an admin first.': 'Ви тут єдиний адміністратор, а інші профілі ще користуються цим сервером. Спершу призначте адміністратором когось іншого.','Couldn’t delete the account. Nothing was removed.': 'Не вдалося видалити акаунт. Нічого не видалено.','Your account is gone. Thanks for every rep.': 'Ваш акаунт видалено. Дякуємо за кожне повторення.',+ 'This app can’t confirm with a passkey. Delete your account from openGym in your browser, or add a password there first.': 'Цей застосунок не може підтвердити ключем доступу. Видаліть акаунт в openGym через браузер або спершу задайте там пароль.',}diff --git a/frontend/src/locales/zh-TW.js b/frontend/src/locales/zh-TW.jsindex 57ab42611..2ca9dc667 100644--- a/frontend/src/locales/zh-TW.js+++ b/frontend/src/locales/zh-TW.js@@ -2243,10 +2243,10 @@ export default {'Want a copy first? Export a backup. You can import it into openGym anytime.': '想先留一份?匯出一個備份。隨時都能再匯入 openGym。','Type {0} to confirm.': '輸入 {0} 以確認。','Account name': '帳號名稱',- 'Deleting…': '正在刪除…','Delete forever': '永久刪除','That is not your account name.': '這不是你的帳號名稱。','You’re the only admin here, and other profiles still use this server. Make someone else an admin first.': '你是這裡唯一的管理員,而且還有其他個人檔案在使用此伺服器。請先讓其他人成為管理員。','Couldn’t delete the account. Nothing was removed.': '無法刪除帳號。沒有刪除任何內容。','Your account is gone. Thanks for every rep.': '你的帳號已刪除。感謝每一次訓練。',+ 'This app can’t confirm with a passkey. Delete your account from openGym in your browser, or add a password there first.': '此 App 無法以通行密鑰確認。請在瀏覽器中的 openGym 刪除帳號,或先在那裡設定密碼。',}diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex c44154a71..b0f4d6ac4 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -2250,10 +2250,10 @@ export default {'Want a copy first? Export a backup. You can import it into openGym anytime.': '想先留一份?导出一个备份。随时可以再导入 openGym。','Type {0} to confirm.': '输入 {0} 以确认。','Account name': '账号名称',- 'Deleting…': '正在删除…','Delete forever': '永久删除','That is not your account name.': '这不是你的账号名称。','You’re the only admin here, and other profiles still use this server. Make someone else an admin first.': '你是这里唯一的管理员,而且还有其他档案在使用此服务器。请先让其他人成为管理员。','Couldn’t delete the account. Nothing was removed.': '无法删除账号。没有删除任何内容。','Your account is gone. Thanks for every rep.': '你的账号已删除。感谢每一次训练。',+ 'This app can’t confirm with a passkey. Delete your account from openGym in your browser, or add a password there first.': '此应用无法用通行密钥确认。请在浏览器中的 openGym 删除账号,或先在那里设置密码。',}diff --git a/frontend/src/store/useStore.account-delete.test.jsx b/frontend/src/store/useStore.account-delete.test.jsxindex a2f74b2bc..438900c33 100644--- a/frontend/src/store/useStore.account-delete.test.jsx+++ b/frontend/src/store/useStore.account-delete.test.jsx@@ -39,11 +39,11 @@ afterEach(() => {})describe('deleteAccount', () => {- it('asks the server with the typed name, then signs this device out and keeps nothing of the account', async () => {+ it('asks the server with the typed name and the owner’s proof, then signs this device out and keeps nothing of the account', async () => {api.mockResolvedValue({ ok: true })- await useStore.getState().deleteAccount('One')+ await useStore.getState().deleteAccount('One', { current: 'correct horse battery staple' })- expect(api).toHaveBeenCalledWith('/api/account/delete', { method: 'POST', body: JSON.stringify({ name: 'One' }) })+ expect(api).toHaveBeenCalledWith('/api/account/delete', { method: 'POST', body: JSON.stringify({ name: 'One', current: 'correct horse battery staple' }) })const st = useStore.getState()expect(st.user).toBeNull()expect(st.S.workouts).toEqual([])diff --git a/frontend/src/store/useStore.js b/frontend/src/store/useStore.jsindex a060b3b32..492e65808 100644--- a/frontend/src/store/useStore.js+++ b/frontend/src/store/useStore.js@@ -1824,14 +1824,15 @@ export const useStore = create((set, get) => {},// Settings → "Delete my account": the server removes the profile and everything of it- // (POST /api/account/delete, `name` typed back to confirm), then this device ends where a- // sign-out leaves it, and a phone goes back to local-only as a disconnect does. Nothing is- // kept aside: there is no account left for kept changes or a running workout to come back to.- // The request is not swallowed: refused (the name, the last admin) or not answered, nothing- // here changes and the caller says why.- async deleteAccount(name) {+ // (POST /api/account/delete, `name` typed back to confirm, `proof` the owner's: a passkey+ // assertion or the current password, from ProveOwner in components/PasswordAuth.jsx), then+ // this device ends where a sign-out leaves it, and a phone goes back to local-only as a+ // disconnect does. Nothing is kept aside: there is no account left for kept changes or a+ // running workout to come back to. The request is not swallowed: refused (the name, the+ // proof, the last admin) or not answered, nothing here changes and the caller says why.+ async deleteAccount(name, proof = {}) {const uid = get().user?.id- await api('/api/account/delete', { method: 'POST', body: JSON.stringify({ name }) })+ await api('/api/account/delete', { method: 'POST', body: JSON.stringify({ name, ...proof }) })await stopTimers()const all = await readStashes()const key = stashKey(serverBase(), uid)