我正在使用 Firebase 网页版,并尝试使用电子邮件和密码注册用户,我已完成文档中所说的所有操作,但由于某种原因无法正常工作。
这是我的提交功能:
function submitForm(){
var email = document.getElementById("email").value;
var password = document.getElementById("password").value;
console.log(email, password);
firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) {
var errorCode = error.code;
var errorMessage = error.message;
alert("oof not valid info brochocho");
});
window.location = 'index.html';
alert("registered");
};
最佳答案
`window.location = 'index.html';
在注册完成之前您将重定向到另一个页面。您应该将此行放在 createUserWithEmailAndPassword
返回的 Promise 的 then block 中。
关于javascript - Firebase电子邮件/密码身份验证未注册用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53566794/