aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/reset-password.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-07-05 13:26:25 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-07-05 14:14:16 +0200
commit6fcd19ba737f1f5614a56c6925adb882dea43b8d (patch)
tree3365a96d82bc7f00ae504a568725c8e914150cf8 /scripts/reset-password.ts
parent5fe7e898316e18369c3e1aba307b55077adc7bfb (diff)
downloadPeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.tar.gz
PeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.tar.zst
PeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.zip
Move to promises
Closes https://github.com/Chocobozzz/PeerTube/issues/74
Diffstat (limited to 'scripts/reset-password.ts')
-rwxr-xr-xscripts/reset-password.ts26
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
14db.init(true, function () { 14db.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})