X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=scripts%2Freset-password.js;h=49a481a18ae515a8e9a30e1fd49f03225fe3b521;hb=72329aaa28bcbb678443900233cc47cff7ba1509;hp=e5f59a2672b68fb9d78e05026856802325148c22;hpb=7df5e5e4b1602ce412b310dd88c83bac937d0a35;p=github%2FChocobozzz%2FPeerTube.git diff --git a/scripts/reset-password.js b/scripts/reset-password.js index e5f59a267..49a481a18 100755 --- a/scripts/reset-password.js +++ b/scripts/reset-password.js @@ -2,19 +2,15 @@ 'use strict' -// TODO: document this script - const program = require('commander') -const constants = require('../server/initializers/constants') const db = require('../server/initializers/database') program .option('-u, --user [user]', 'User') - .option('-p, --password [new password]', 'New password') .parse(process.argv) -if (program.user === undefined || program.password === undefined) { +if (program.user === undefined) { console.error('All parameters are mandatory.') process.exit(-1) } @@ -31,15 +27,32 @@ db.init(true, function () { return } - user.password = program.password - user.save().asCallback(function (err) { - if (err) { - console.error(err) - return + const readline = require('readline') + const Writable = require('stream').Writable + const mutableStdout = new Writable({ + write: function (chunk, encoding, callback) { + callback() } + }) + const rl = readline.createInterface({ + input: process.stdin, + output: mutableStdout, + terminal: true + }) + + console.log('New password?') + rl.on('line', function (password) { + user.password = password + + user.save().asCallback(function (err) { + if (err) { + console.error(err) + } else { + console.log('User password updated.') + } - console.log('User pasword updated.') - process.exit(0) + process.exit(0) + }) }) }) })