añadido error de pass invalida

This commit is contained in:
Guillermo Bonet 2022-06-20 14:32:04 +02:00
parent 2e9b91c2fe
commit dac484780c
1 changed files with 23 additions and 6 deletions

29
main.js
View File

@ -41,17 +41,26 @@ async function main(){
output: process.stdout
});
rl.stdoutMuted = true;
rl.query = "Password : ";
const answer = await new Promise(resolve => {
rl.question(colors.yellow('Enter your password: '), resolve);
rl._writeToOutput = function _writeToOutput(stringToWrite) {
if (rl.stdoutMuted)
rl.output.write("*");
else
rl.output.write(stringToWrite);
};
});
const passw = `${answer}`;
if (!answer) {
console.error(`You need to put a password`.red);
process.exit(0);
}
const passw = `${answer}`;
const credentials = `Basic ` + Buffer.from(`${user}:${passw}`).toString('base64');
rl.history = rl.history.slice(1)
rl.close();
const credentials = `Basic ` + Buffer.from(`${user}:${passw}`).toString('base64');
console.clear();
console.log(colors.green.bold(`-------------------- Starting process --------------------`));
@ -59,13 +68,18 @@ async function main(){
let responseAllUID = await fetch(urlDashboards, {
method: "GET",
headers: {
"Authorization": credentials,
"Content-Type" : "application/json"
"Authorization": credentials
}
});
let allUID = await responseAllUID.json();
if (allUID.message=='invalid username or password') {
console.error(`Invalid username or password`.red);
process.exit(0);
}
for (let i=0; i < allUID.length; i++) {
let url = urlUID + allUID[i].uid;
@ -75,6 +89,9 @@ async function main(){
"Authorization": credentials,
}
});
let data = await response.json();
let isFound = false;