1 | #!/usr/bin/env node
|
2 |
|
3 |
|
4 | const Redis = require('ioredis').Cluster;
|
5 | const assert = require('assert');
|
6 | const conf = require('../lib/config');
|
7 |
|
8 | const config = conf.get('/', { env: process.env.NODE_ENV });
|
9 | const redisConfig = config.redis;
|
10 | const { updatePassword } = require('../lib/actions/updatePassword');
|
11 |
|
12 | const username = process.argv[2];
|
13 | const password = process.argv[3];
|
14 | assert(username, 'must provide id as argv[2]');
|
15 | assert(password, 'must provide password of token as argv[3]');
|
16 |
|
17 |
|
18 | const redis = new Redis(redisConfig.hosts, ({ ...redisConfig.options, lazyConnect: true }));
|
19 |
|
20 |
|
21 | redis
|
22 | .connect()
|
23 | .bind({ redis })
|
24 | .return([username, password])
|
25 | .spread(updatePassword)
|
26 | .then(() => {
|
27 | console.info('\nSet password for %s to "%s"\n', username, password);
|
28 | return redis.disconnect();
|
29 | })
|
30 | .catch((err) => setImmediate(() => { throw err; }));
|