// Clears the admin password so the next visit to /admin (from the LAN) can set a new one. // Also rotates the session secret, signing out every existing admin session. // Usage: docker exec -u 10001 hobbs-family-organizer-organizer-1 node container/reset-admin.mjs import { randomBytes } from "node:crypto"; import { rename, writeFile } from "node:fs/promises"; const path = `${process.env.ORGANIZER_DATA_DIR || "/data"}/auth.json`; const temporary = `${path}.reset.tmp`; await writeFile( temporary, `${JSON.stringify({ passwordHash: "", sessionSecret: randomBytes(32).toString("base64url") }, null, 2)}\n`, { mode: 0o600 }, ); await rename(temporary, path); console.log("Admin password cleared. Visit /admin from the LAN to set a new one.");