Friends, could you explain me and if possible, give a solution to the following problem?
My if
where it says:
if(aux == 0)
{
console.log("não encontrado");
}
It is running before the check in firebase, this only the first time I open the application. Below is the code for my function:
var refUser = new Firebase("//endereçodofirebaseescondido");
var key;
function logar() {
var aux = 0;
var login = document.getElementById("form1").elements.namedItem("login").value;
var pass = document.getElementById("form1").elements.namedItem("senha").value;
refUser.orderByChild("login").equalTo(login).on("child_added", function(snapshot) {
key = snapshot.key();
refUser.orderByChild("pass").equalTo(pass).on("child_added", function(snap) {
aux = 1;
console.log(pass);
if (key == snap.key()) {
console.log("senha e login conferem");
} else {
console.log("não encontrado");
}
});
});
if (aux == 0) {
console.log("não encontrado");
}
}