]> git.cworth.org Git - lmno-server/blob - lmno-passwd.js
Add some autofocus attributes to several forms
[lmno-server] / lmno-passwd.js
1 const bcrypt = require('bcrypt');
2
3 /* The sigint:true property allows the user to abort the entire program
4  * with Control-C (rather than having to abort through each prompt).
5  */
6 const prompt = require('prompt-sync')({
7   sigint: true
8 });
9
10 const username = prompt("Username: ");
11
12 while (true) {
13   /* Use "echo:'*'" to avoid displaying the password while typing. */
14   var password = prompt("New password: ", {echo: '*'});
15   const password_again = prompt("Re-type new password: ", {echo: '*'});
16
17   if (password === password_again)
18     break;
19
20   console.log("Passwords do not match. Try again.");
21 }
22
23 const hash = bcrypt.hashSync(password, 12);
24
25 console.log(`Add the following block to the 'users' object in lmno-config.js:
26
27     "${username}": {
28       "password_hash_bcrypt": "${hash}",
29       "role": "user"
30     }
31 `);