Skip to content

Commit

Permalink
Implement coder#4 - fix password via CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed Mar 5, 2019
1 parent 4028e33 commit e1099f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions doc/self-hosted/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ OPTIONS
-v, --version show CLI version
--cert=cert
--cert-key=cert-key
--password=password
--help show CLI help
```

Expand Down
17 changes: 11 additions & 6 deletions packages/server/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit e1099f0

Please sign in to comment.