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._consolidatorTempPassword = consPw;
|
||||||
db.users.push(cons);
|
db.users.push(cons);
|
||||||
|
const tmpPws = [];
|
||||||
START_COMPANIES.forEach(function (name, i) {
|
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,
|
id: "u_" + i,
|
||||||
role: "subsidiary",
|
role: "subsidiary",
|
||||||
name: "",
|
name: "",
|
||||||
@ -95,9 +99,16 @@ function seed() {
|
|||||||
person: "",
|
person: "",
|
||||||
phone: "",
|
phone: "",
|
||||||
login: "c" + (i + 1),
|
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.users.push(u);
|
||||||
});
|
});
|
||||||
|
db._firstRunSubsidiaryPasswords = tmpPws.join("\n");
|
||||||
writeRaw(db);
|
writeRaw(db);
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,6 +27,11 @@ if (GENERATED_PASSWORD) {
|
|||||||
delete DB._consolidatorTempPassword;
|
delete DB._consolidatorTempPassword;
|
||||||
store.save(DB);
|
store.save(DB);
|
||||||
}
|
}
|
||||||
|
if (DB._firstRunSubsidiaryPasswords) {
|
||||||
|
log("FIRST RUN: subsidiary logins/passwords:\n" + DB._firstRunSubsidiaryPasswords);
|
||||||
|
delete DB._firstRunSubsidiaryPasswords;
|
||||||
|
store.save(DB);
|
||||||
|
}
|
||||||
|
|
||||||
const sessions = {};
|
const sessions = {};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user