-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
27 lines (24 loc) · 851 Bytes
/
index.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
document.getElementById("loginForm").addEventListener("submit",(event)=>{
event.preventDefault()
})
firebase.auth().onAuthStateChanged((user)=>{
if(user){
location.replace("welcome.html")
}
})
function login(){
const email = document.getElementById("email").value
const password = document.getElementById("password").value
firebase.auth().signInWithEmailAndPassword(email, password)
.catch((error)=>{
document.getElementById("error").innerHTML = error.message
})
}
function signUp(){
const email = document.getElementById("email").value
const password = document.getElementById("password").value
firebase.auth().createUserWithEmailAndPassword(email, password)
.catch((error) => {
document.getElementById("error").innerHTML = error.message
});
}