// Add or update a dashboard login from the command line (backup for when no admin can sign in). // Normally admins add teammates in the dashboard: Settings → Team members. // npm run add-user -- you@agency.com "Your Name" admin (generates a password) // npm run add-user -- you@agency.com "Your Name" member MyPass123 (sets this password) // Writes to data/dashboard/users.json (hashed). The plain password is shown once. import crypto from "node:crypto"; import { upsertFromCli } from "../users.js"; const [email, name = "", role = "member", given] = process.argv.slice(2); if (!email || !/^[^@\s]+@[^@\s]+$/.test(email) || !["admin", "member"].includes(role)) { console.error('Usage: npm run add-user -- you@agency.com "Your Name" admin|member [password]'); process.exit(1); } const password = given || crypto.randomBytes(9).toString("base64url"); try { upsertFromCli({ email, name, role, password }); } catch (e) { console.error(e.message); process.exit(1); } console.log(`Saved ${role} ${email}. Any open sessions for this login are signed out.`); if (!given) console.log(`Password (shown once, share it privately): ${password}`);