feat: log seeded subsidiary passwords once on first run
This commit is contained in:
parent
3dc2ad55fb
commit
3adb655b0a
15
lib/store.js
15
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;
|
||||
}
|
||||
|
||||
@ -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 = {};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user