aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/reset-password.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-12 21:06:32 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-12 21:06:32 +0200
commit75d612ce3ca9d6f69fe8e4e83dc3070d9ab56615 (patch)
tree016f64d0fc6cfee533516be40d76eaca1b1f837e /scripts/reset-password.js
parent7593a21d13baad422efedfb658d7ceda4e0a8c6b (diff)
downloadPeerTube-75d612ce3ca9d6f69fe8e4e83dc3070d9ab56615.tar.gz
PeerTube-75d612ce3ca9d6f69fe8e4e83dc3070d9ab56615.tar.zst
PeerTube-75d612ce3ca9d6f69fe8e4e83dc3070d9ab56615.zip
Convert scripts to typescript
Diffstat (limited to 'scripts/reset-password.js')
-rwxr-xr-xscripts/reset-password.js58
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
5const program = require('commander')
6
7const db = require('../server/initializers/database')
8
9program
10 .option('-u, --user [user]', 'User')
11 .parse(process.argv)
12
13if (program.user === undefined) {
14 console.error('All parameters are mandatory.')
15 process.exit(-1)
16}
17
18db.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})