-
Notifications
You must be signed in to change notification settings - Fork 1
/
singnup.js
48 lines (41 loc) · 1.26 KB
/
singnup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { initializeApp } from "firebase/app";
import { getAnalytics } from "firebase/analytics";
document.getElementById('login-form').addEventListener('submit', (event)=> {
event.preventDefault();
login();
})
const firebaseConfig = {
apiKey: "AIzaSyBZnn4RPMlAdECe6k4kgJTRUBflgR4hTEA",
authDomain: "travel-buddy-471e0.firebaseapp.com",
projectId: "travel-buddy-471e0",
storageBucket: "travel-buddy-471e0.appspot.com",
messagingSenderId: "785129601834",
appId: "1:785129601834:web:4a82e0e7c5fe4668983c53",
measurementId: "G-PMQWZR7Y8L"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
firebase.auth().onAuthStateChanged((user) => {
if (user) {
window.location.assign('/deep-home.html')
}
else {
alert('user is not signed in')
}
})
function login(){
const email = document.getElementById('email').value
const password = document.getElementById('password').value
firebase.auth().signInWithEmailAndPassword(email, password)
.then((userCredential) => {
// Signed in
const user = userCredential.user;
console.log("User signed in:", user)
})
.catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
console.log(errorMessage)
});
}