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
Admin activity log: label the first-user admin event
Duarte Santosfb4c7fc5aeb7
diff --git a/frontend/src/lib/audit.js b/frontend/src/lib/audit.jsindex 1d5bbeec9..173fc2231 100644--- a/frontend/src/lib/audit.js+++ b/frontend/src/lib/audit.js@@ -60,6 +60,8 @@ const LABELS = {'admin.invite.create': 'Created an invite code','admin.invite.revoke': 'Revoked an invite code','admin.audit.clear': 'Cleared the activity log',+ // FIRST_USER_ADMIN=1: the first profile on a fresh instance is made admin as it signs up.+ 'admin.first-user': 'Became admin as the first profile','admin.denied': 'Blocked from the admin dashboard',// Photos and videos of custom exercises: "Reset everything" clearing a profile's files, and the// upload or clean-up throttle pausing a profile (`msg` says which).diff --git a/frontend/src/lib/audit.test.js b/frontend/src/lib/audit.test.jsindex 2b5f602fe..2b2d741d9 100644--- a/frontend/src/lib/audit.test.js+++ b/frontend/src/lib/audit.test.js@@ -8,11 +8,15 @@ import { auditCat, auditLabel, auditReason, auditLine, auditAct, fmtWhen } from// If a new one is added there without a label here, the first test fails rather than the// dashboard quietly printing a dotted identifier at a person.const SERVER = readFileSync(new URL('../../../api/server.js', import.meta.url), 'utf8')-const EVENTS = [...new Set([...SERVER.matchAll(/audit\(req, '([a-z.]+)'/g)].map(m => m[1]))]+// Every quoted auth./admin./media. name, not only `audit(req, '…'`: a name with a hyphen+// ('admin.first-user') or one picked by a ternary slipped past that pattern and reached the+// dashboard raw.+const EVENTS = [...new Set([...SERVER.matchAll(/['"`]((?:auth|admin|media)\.[a-z0-9.-]+)['"`]/g)].map(m => m[1]))]const REASONS = [...new Set([...SERVER.matchAll(/msg: '([a-z-]+)'/g)].map(m => m[1]))]describe('auditLabel', () => {it('has a sentence for every event the server emits', () => {+ expect(EVENTS).toContain('admin.first-user')for (const ev of EVENTS) {expect(auditLabel(ev), ev).not.toBe(ev)expect(auditLabel(ev)).toMatch(/^[A-Z]/)