loginForm.addEventListener('submit', (e) => {
e.preventDefault();
const email = loginForm.email.value;
const password = loginForm.password.value;
firebase.auth().signInWithEmailAndPassword(email, password)
.then((user) => {
console.log('logged in', user);
loginForm.reset();
})
.catch((error) => {
loginForm.querySelector('.error').textContent = error.message;
});
});
Here firebase function works but when I type this it suddenly says that firebase is undefined. Thanks in advance!
firebase.auth().onAuthStateChanged((user) => {
if (user) {
authWrapper.classList.remove('open');
authModals.forEach(modal => modal.classList.remove('active'));
} else {
authWrapper.classList.add('open');
authModals[0].classList.add('active');
}
}).then((user) => {
window.location.href = "Ucionica.html";
});