Skip to content

Commit 00a9941

Browse files
committed
mask password in input for tenant password when recevied from stdin prompt
1 parent 3643a5b commit 00a9941

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

wmiocli.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,17 @@ const { Command, Option } = require('commander');
2121
const { exit } = require('process');
2222
const readline = require('readline-sync');
2323

24-
function readFromConsole(question)
24+
function readFromConsole(question,isPassword)
2525
{
26-
var answer = readline.question("\x1b[32m" + question + "\x1b[0m");
26+
var answer;
27+
if(isPassword !== undefined && isPassword!==null && isPassword==true)
28+
{
29+
answer = readline.question("\x1b[32m" + question + "\x1b[0m",{hideEchoBack: true});
30+
}
31+
else
32+
{
33+
answer = readline.question("\x1b[32m" + question + "\x1b[0m");
34+
}
2735
return answer;
2836
}
2937

@@ -52,7 +60,7 @@ function checkOptions(){
5260
}
5361

5462
if(program.opts().password == undefined){
55-
tenantPw = readFromConsole('Please type your tenant User Password: ');
63+
tenantPw = readFromConsole('Please type your tenant User Password: ',true);
5664
}
5765
else{
5866
tenantPw = program.opts().password

0 commit comments

Comments
 (0)