diff options
Diffstat (limited to 'scripts/reset-password.js')
-rwxr-xr-x | scripts/reset-password.js | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/scripts/reset-password.js b/scripts/reset-password.js deleted file mode 100755 index 49a481a18..000000000 --- a/scripts/reset-password.js +++ /dev/null | |||
@@ -1,58 +0,0 @@ | |||
1 | #!/usr/bin/env node | ||
2 | |||
3 | 'use strict' | ||
4 | |||
5 | const program = require('commander') | ||
6 | |||
7 | const db = require('../server/initializers/database') | ||
8 | |||
9 | program | ||
10 | .option('-u, --user [user]', 'User') | ||
11 | .parse(process.argv) | ||
12 | |||
13 | if (program.user === undefined) { | ||
14 | console.error('All parameters are mandatory.') | ||
15 | process.exit(-1) | ||
16 | } | ||
17 | |||
18 | db.init(true, function () { | ||
19 | db.User.loadByUsername(program.user, function (err, user) { | ||
20 | if (err) { | ||
21 | console.error(err) | ||
22 | return | ||
23 | } | ||
24 | |||
25 | if (!user) { | ||
26 | console.error('User unknown.') | ||
27 | return | ||
28 | } | ||
29 | |||
30 | const readline = require('readline') | ||
31 | const Writable = require('stream').Writable | ||
32 | const mutableStdout = new Writable({ | ||
33 | write: function (chunk, encoding, callback) { | ||
34 | callback() | ||
35 | } | ||
36 | }) | ||
37 | const rl = readline.createInterface({ | ||
38 | input: process.stdin, | ||
39 | output: mutableStdout, | ||
40 | terminal: true | ||
41 | }) | ||
42 | |||
43 | console.log('New password?') | ||
44 | rl.on('line', function (password) { | ||
45 | user.password = password | ||
46 | |||
47 | user.save().asCallback(function (err) { | ||
48 | if (err) { | ||
49 | console.error(err) | ||
50 | } else { | ||
51 | console.log('User password updated.') | ||
52 | } | ||
53 | |||
54 | process.exit(0) | ||
55 | }) | ||
56 | }) | ||
57 | }) | ||
58 | }) | ||