añadido error de pass invalida
This commit is contained in:
parent
2e9b91c2fe
commit
dac484780c
29
main.js
29
main.js
|
@ -41,17 +41,26 @@ async function main(){
|
||||||
output: process.stdout
|
output: process.stdout
|
||||||
});
|
});
|
||||||
|
|
||||||
|
rl.stdoutMuted = true;
|
||||||
|
|
||||||
|
rl.query = "Password : ";
|
||||||
const answer = await new Promise(resolve => {
|
const answer = await new Promise(resolve => {
|
||||||
rl.question(colors.yellow('Enter your password: '), 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) {
|
if (!answer) {
|
||||||
console.error(`You need to put a password`.red);
|
console.error(`You need to put a password`.red);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
const passw = `${answer}`;
|
rl.history = rl.history.slice(1)
|
||||||
|
|
||||||
const credentials = `Basic ` + Buffer.from(`${user}:${passw}`).toString('base64');
|
|
||||||
rl.close();
|
rl.close();
|
||||||
|
const credentials = `Basic ` + Buffer.from(`${user}:${passw}`).toString('base64');
|
||||||
|
|
||||||
console.clear();
|
console.clear();
|
||||||
console.log(colors.green.bold(`-------------------- Starting process --------------------`));
|
console.log(colors.green.bold(`-------------------- Starting process --------------------`));
|
||||||
|
@ -59,13 +68,18 @@ async function main(){
|
||||||
let responseAllUID = await fetch(urlDashboards, {
|
let responseAllUID = await fetch(urlDashboards, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
"Authorization": credentials,
|
"Authorization": credentials
|
||||||
"Content-Type" : "application/json"
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let allUID = await responseAllUID.json();
|
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++) {
|
for (let i=0; i < allUID.length; i++) {
|
||||||
|
|
||||||
let url = urlUID + allUID[i].uid;
|
let url = urlUID + allUID[i].uid;
|
||||||
|
@ -75,6 +89,9 @@ async function main(){
|
||||||
"Authorization": credentials,
|
"Authorization": credentials,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let data = await response.json();
|
let data = await response.json();
|
||||||
|
|
||||||
let isFound = false;
|
let isFound = false;
|
||||||
|
|
Loading…
Reference in New Issue