feat: log seeded subsidiary passwords once on first run

This commit is contained in:
samruk_3 2026-09-21 09:57:47 +00:00
parent 3dc2ad55fb
commit 3adb655b0a
2 changed files with 18 additions and 2 deletions

View File

@ -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;
}

View File

@ -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 = {};