diff options
Diffstat (limited to 'scripts/reset-password.ts')
-rwxr-xr-x | scripts/reset-password.ts | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/scripts/reset-password.ts b/scripts/reset-password.ts index 50e11c69c..09f27bfa4 100755 --- a/scripts/reset-password.ts +++ b/scripts/reset-password.ts | |||
@@ -11,13 +11,11 @@ if (program.user === undefined) { | |||
11 | process.exit(-1) | 11 | process.exit(-1) |
12 | } | 12 | } |
13 | 13 | ||
14 | db.init(true, function () { | 14 | db.init(true) |
15 | db.User.loadByUsername(program.user, function (err, user) { | 15 | .then(() => { |
16 | if (err) { | 16 | return db.User.loadByUsername(program.user) |
17 | console.error(err) | 17 | }) |
18 | return | 18 | .then(user => { |
19 | } | ||
20 | |||
21 | if (!user) { | 19 | if (!user) { |
22 | console.error('User unknown.') | 20 | console.error('User unknown.') |
23 | return | 21 | return |
@@ -40,15 +38,9 @@ db.init(true, function () { | |||
40 | rl.on('line', function (password) { | 38 | rl.on('line', function (password) { |
41 | user.password = password | 39 | user.password = password |
42 | 40 | ||
43 | user.save().asCallback(function (err) { | 41 | user.save() |
44 | if (err) { | 42 | .then(() => console.log('User password updated.')) |
45 | console.error(err) | 43 | .catch(err => console.error(err)) |
46 | } else { | 44 | .finally(() => process.exit(0)) |
47 | console.log('User password updated.') | ||
48 | } | ||
49 | |||
50 | process.exit(0) | ||
51 | }) | ||
52 | }) | 45 | }) |
53 | }) | 46 | }) |
54 | }) | ||