aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xscripts/reset-password.js34
1 files changed, 25 insertions, 9 deletions
diff --git a/scripts/reset-password.js b/scripts/reset-password.js
index 6a00b37eb..5ae3af9ea 100755
--- a/scripts/reset-password.js
+++ b/scripts/reset-password.js
@@ -10,10 +10,9 @@ const db = require('../server/initializers/database')
10 10
11program 11program
12 .option('-u, --user [user]', 'User') 12 .option('-u, --user [user]', 'User')
13 .option('-p, --password [new password]', 'New password')
14 .parse(process.argv) 13 .parse(process.argv)
15 14
16if (program.user === undefined || program.password === undefined) { 15if (program.user === undefined) {
17 console.error('All parameters are mandatory.') 16 console.error('All parameters are mandatory.')
18 process.exit(-1) 17 process.exit(-1)
19} 18}
@@ -30,15 +29,32 @@ db.init(true, function () {
30 return 29 return
31 } 30 }
32 31
33 user.password = program.password 32 const readline = require('readline')
34 user.save().asCallback(function (err) { 33 const Writable = require('stream').Writable
35 if (err) { 34 const mutableStdout = new Writable({
36 console.error(err) 35 write: function (chunk, encoding, callback) {
37 return 36 callback()
38 } 37 }
38 })
39 const rl = readline.createInterface({
40 input: process.stdin,
41 output: mutableStdout,
42 terminal: true
43 })
44
45 console.log('New password?')
46 rl.on('line', function (password) {
47 user.password = password
48
49 user.save().asCallback(function (err) {
50 if (err) {
51 console.error(err)
52 } else {
53 console.log('User password updated.')
54 }
39 55
40 console.log('User pasword updated.') 56 process.exit(0)
41 process.exit(0) 57 })
42 }) 58 })
43 }) 59 })
44}) 60})