aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/reset-password.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-01-23 22:50:29 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-01-23 22:50:29 +0100
commitc129e2a1677a51b1adae3c08839fb397b565a57e (patch)
treefc7fc1f2669a28e847560e36a726cac4ed88e790 /scripts/reset-password.js
parentb99290b1d5d736083513fb8f66e91f61bfe07e0b (diff)
downloadPeerTube-c129e2a1677a51b1adae3c08839fb397b565a57e.tar.gz
PeerTube-c129e2a1677a51b1adae3c08839fb397b565a57e.tar.zst
PeerTube-c129e2a1677a51b1adae3c08839fb397b565a57e.zip
Do not let admin put password on cli argument when reseting password
Diffstat (limited to 'scripts/reset-password.js')
-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})