-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
43 lines (33 loc) · 1.09 KB
/
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//to prevent index.html? on submission
document.getElementById("loginForm").addEventListener("submit",(event)=>{
event.preventDefault()
})
//changing the webpage on authorization
firebase.auth().onAuthStateChanged((user)=>{
if(user){
location.replace("welcome.html")
}
})
//Login function
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
})
}
document.getElementById("Signup-page").onclick = function () {
location.href = "Signup.html";
};
// function to get new password on forgetting old password
function forgotPass(){
const email = document.getElementById("email").value
firebase.auth().sendPasswordResetEmail(email)
.then(() => {
alert("reset link sent to your email id")
})
.catch((error) => {
document.getElementById("error").innerHTML = error.message
});
}