When I Login with the correct credientials the alert thats being pulled is Login failed: Firebase: Error (auth/user-not-found). . Below is my javascript code. I’ve tried making new users and more.
Javascript:
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.1.0/firebase-app.js";
import { getAuth, signInWithEmailAndPassword } from "https://www.gstatic.com/firebasejs/10.1.0/firebase-auth.js";
import { setLogLevel } from "https://www.gstatic.com/firebasejs/10.1.0/firebase-app.js"; // Import setLogLevel from firebase/app
const firebaseConfig = {
apiKey: "YOUR_API_KEY",
authDomain: "YOUR_AUTH_DOMAIN",
databaseURL: "YOUR_DATABASE_URL",
projectId: "YOUR_PROJECT_ID",
storageBucket: "YOUR_STORAGE_BUCKET",
messagingSenderId: "YOUR_MESSAGING_SENDER_ID",
appId: "YOUR_APP_ID",
measurementId: "YOUR_MEASUREMENT_ID"
};
const app = initializeApp(firebaseConfig);
const auth = getAuth();
// Set Firebase debugging to get detailed error messages
setLogLevel("debug");
const loginForm = document.querySelector("#loginForm");
const loginEmail = document.querySelector("#loginEmail");
const loginPassword = document.querySelector("#loginPassword");
loginForm.addEventListener("submit", async (e) => {
e.preventDefault();
const userEmail = loginEmail.value;
const userPassword = loginPassword.value;
try {
const userCredential = await signInWithEmailAndPassword(auth, userEmail, userPassword);
const user = userCredential.user;
window.location.href = "dashboard.html";
} catch (error) {
const errorMessage = error.message;
alert("Login failed: " + errorMessage);
}
});