Skip to content

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.

Merge branch 'security-fixes' into stores

Duarte Santos9acd24c51d6a
diff --cc api/server.js
index 35e6ca669,491e99a28..26aaf5dad
--- a/api/server.js
+++ b/api/server.js
@@@ -2557,8 -2628,20 +2706,10 @@@ const routes =
if (!u) return json(res, 404, { error: 'no such user' });
if (u.id === admin.id) return json(res, 400, { error: 'you cannot delete your own account' });
if (isAdmin(u) && db.users.filter(isAdmin).length <= 1) return json(res, 400, { error: 'cannot delete the last admin' });
+ if (isOwner(u)) return json(res, 400, { error: 'the owner cannot be deleted; hand the role to another admin first' });
+ if (isAdmin(u) && !isOwner(admin)) { audit(req, 'admin.denied', { ok: false, user: admin, target: u }); return json(res, 403, { error: 'only the owner can delete an admin' }); }
const name = u.name;
- db.users = db.users.filter(x => x.id !== u.id);
- db.creds = (db.creds || []).filter(c => c.userId !== u.id);
- db.subs = (db.subs || []).filter(x => x.userId !== u.id);
- dropDeviceLinks(db, u.id);
- presence.delete(u.id);
- // The training history and any Coach credential of theirs, both outside db.json.
- try { fs.unlinkSync(stateFile(u.id)); } catch { /* already gone */ }
- try { coachConfig.clearProfileAuth(u.id); } catch { /* nothing stored */ }
- // Their photos and videos — the one place a profile's folder under uploads/ is removed.
- try { MEDIA.removeUser(u.id); } catch (e) { console.error('media: could not remove uploads of', u.id, e.message); }
- saveDb();
+ removeAccount(u);
// Logged with the name, because the id is about to mean nothing to anyone reading this back.
audit(req, 'admin.user.delete', { user: admin, msg: name });
json(res, 200, { ok: true, id: u.id });
diff --cc api/test/prompt-split.test.js
index deb80c373,3de86f0c5..42e713ce7
--- a/api/test/prompt-split.test.js
+++ b/api/test/prompt-split.test.js
@@@ -5,6 -5,7 +5,7 @@@ import { SCHEMAS } from '../coach/core/
import { build, FULL_DETAIL_SESSIONS } from '../coach/core/payload.js';
import { chatCompletionsSpec } from '../coach/core/adapters/openai.js';
import { validatePlan } from '../coach/core/validate.js';
-import { recent as fixtureDay } from './helpers.mjs';
++import { D as fixtureDay } from './helpers.mjs';
const S = (workouts = []) => ({
lang: 'en', unit: 'kg', routines: [{ id: 'r1', name: 'A', ex: [{ id: '0001', sets: 3, reps: 8 }] }],