From 3adb655b0aa5f85121bf6ed3281123a322db8110 Mon Sep 17 00:00:00 2001 From: samruk_3 Date: Mon, 21 Sep 2026 09:57:47 +0000 Subject: [PATCH] feat: log seeded subsidiary passwords once on first run --- lib/store.js | 15 +++++++++++++-- server.js | 5 +++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/store.js b/lib/store.js index 52201e1..3c700f9 100644 --- a/lib/store.js +++ b/lib/store.js @@ -86,8 +86,12 @@ function seed() { }); db._consolidatorTempPassword = consPw; db.users.push(cons); + const tmpPws = []; START_COMPANIES.forEach(function (name, i) { - const u = makeUser({ + const pw = randPassword(12); + const salt = crypto.randomBytes(32); + const hash = crypto.scryptSync(pw, salt, 32); + const u = { id: "u_" + i, role: "subsidiary", name: "", @@ -95,9 +99,16 @@ function seed() { person: "", phone: "", login: "c" + (i + 1), - }); + salt: salt.toString("hex"), + passwordHash: hash.toString("hex"), + active: true, + failedCount: 0, + lockedUntil: 0, + }; + tmpPws.push(name + " | c" + (i + 1) + " | " + pw); db.users.push(u); }); + db._firstRunSubsidiaryPasswords = tmpPws.join("\n"); writeRaw(db); return db; } diff --git a/server.js b/server.js index 7dd052a..9cb5b96 100644 --- a/server.js +++ b/server.js @@ -27,6 +27,11 @@ if (GENERATED_PASSWORD) { delete DB._consolidatorTempPassword; store.save(DB); } +if (DB._firstRunSubsidiaryPasswords) { + log("FIRST RUN: subsidiary logins/passwords:\n" + DB._firstRunSubsidiaryPasswords); + delete DB._firstRunSubsidiaryPasswords; + store.save(DB); +} const sessions = {};