Implement #4 - fix password via CLI (#5)

This commit is contained in:
Icebob 2019-03-06 09:08:43 +01:00 committed by Kyle Carberry
parent 1d8da2161f
commit 3fbdb2e46c
2 changed files with 12 additions and 6 deletions

View File

@ -48,6 +48,7 @@ OPTIONS
-v, --version show CLI version
--cert=cert
--cert-key=cert-key
--password=password
--help show CLI help
```

View File

@ -26,6 +26,7 @@ export class Entry extends Command {
version: flags.version({ char: "v" }),
"no-auth": flags.boolean({ default: false }),
"allow-http": flags.boolean({ default: false }),
password: flags.string(),
// Dev flags
"bootstrap-fork": flags.string({ hidden: true }),
@ -132,13 +133,17 @@ export class Entry extends Command {
}
});
const passwordLength = 12;
const possible = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
const chars = [];
for (let i = 0; i < passwordLength; i++) {
chars.push(possible[Math.floor(Math.random() * possible.length)]);
let password = flags["password"];
if (!password) {
// Generate a random password
const passwordLength = 12;
const possible = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
const chars = [];
for (let i = 0; i < passwordLength; i++) {
chars.push(possible[Math.floor(Math.random() * possible.length)]);
}
password = chars.join("");
}
const password = chars.join("");
const hasCustomHttps = certData && certKeyData;
const app = await createApp({