Skip to content

Commit f2766f6

Browse files
alxndrsnalxndrsn
authored andcommitted
cli: don't allow supplying password on CLI
1 parent a50a6b8 commit f2766f6

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lib/bin/cli.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,14 @@ const { createUser, promoteUser, setUserPassword } = require('../task/account');
1818

1919
// gets a password interactively if not supplied in cli args.
2020
const prompt = require('prompt');
21-
const ensurePassword = (input, f) => {
22-
if (input != null) return f(input);
23-
21+
const withPassword = (f) => {
2422
prompt.start();
2523
prompt.get([{ name: 'password', hidden: true, replace: '*' }], (_, { password }) => f(password));
2624
};
2725

2826
// command line nonsense (i'm not a huge fan of this library).
2927
const cli = require('cli');
3028
const cliArgs = {
31-
password: [ 'p', 'For user create and set password commands, supplies the password. If not provided, you will be interactively prompted for one.', 'string' ],
3229
email: [ 'u', 'For user create and set password commands, supplies the email.', 'email' ]
3330
};
3431
const cliCommands = [ 'user-create', 'user-promote', 'user-set-password' ];
@@ -37,10 +34,10 @@ cli.parse(cliArgs, cliCommands);
3734
// map commands to tasks.
3835
cli.main((args, options) => {
3936
if (cli.command === 'user-create')
40-
ensurePassword(options.password, (password) => run(createUser(options.email, password)));
37+
withPassword((password) => run(createUser(options.email, password)));
4138
else if (cli.command === 'user-promote')
4239
run(promoteUser(options.email));
4340
else if (cli.command === 'user-set-password')
44-
ensurePassword(options.password, (password) => run(setUserPassword(options.email, password)));
41+
withPassword((password) => run(setUserPassword(options.email, password)));
4542
});
4643

0 commit comments

Comments
 (0)