Weird happens when I try to authenticate new user, the app does not catch any errors but the user is not authenticated however when I debug the code in browser the user gets authenticated. I guess the function terminates before the process of creating a user is finished so when I make the program stop at a brake point while debugging it gives the process enough time to terminate but i don't know how to solve this problem.
<form>
<input type = "text" id = "email" />
<input type = "password" id = "pass" />
<input type = "submit" id = "signup" />
</form>
<script >
var temail = document.getElementById('email');
var tpass = document.getElementById('pass');
var signup = document.getElementById('signup');
signup.addEventListener('click',e =>{
var email = temail.value;
var password = tpass.value;
firebase.auth().createUserWithEmailAndPassword(email, password)
.then(function(user){
console.log(user);
}).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
console.log(errorMessage);
alert(errorCode);
// ...
});
alert('done');
}) ;
</script>
Aucun commentaire:
Enregistrer un commentaire