-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccountHandling2.js
50 lines (34 loc) · 1.02 KB
/
accountHandling2.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
49
50
const logOut = document.getElementById("signOut")
const userEmail = document.querySelector(".userEmail")
const goLoginPage = document.getElementById("goLoginPage")
const auth = firebase.auth()
logOut.classList.add("active")
const logo = document.querySelector("#logo")
// console.log(logo)
logo.addEventListener("click", () => {
window.location.assign("index.html")
})
goLoginPage.addEventListener("click", () => [
window.location.replace("accountPage.html")
])
const logOutFunction = () => {
auth.signOut()
.then(() => {
console.log("you are out")
window.location.assign("accountPage.html")
})
.catch((e) => {
console.log(e)
})
}
auth.onAuthStateChanged(user => {
console.log(user)
if (user) {
userEmail.innerHTML = user.email
logOut.classList.remove("active")
goLoginPage.classList.add("active")
}
})
logOut.addEventListener("click", () => {
logOutFunction()
})