我正在学习如何将Firebase用于大学项目,但我对JS的了解很少,而且我遇到了问题。我想要的是,在登录正确后,用户应该被重定向到X站点,但我不知道如何做到这一点。这就是我目前所拥有的:
const inputEmail = document.getElementById('inputEmail');
const inputPassword = document.getElementById('inputPassword');
const btnIniciarSesion = document.getElementById('btnIniciarSesion');
btnIniciarSesion.addEventListener('click', e => {
const email = inputEmail.value;
const password = inputPassword.value;
const auth = firebase.auth();
const promise = auth.signInWithEmailAndPassword(email, password);
promise.catch(e => console.log(e.message));
});
有关如何做到这一点的任何建议吗?
答案 0 :(得分:1)
试试这个:
auth.signInWithEmailAndPassword(email, password)
.then(user => {
// Sign in success
// Route to site here
}).catch(error => {
console.error(error);
})