-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacountHandling.js
111 lines (88 loc) · 3.25 KB
/
acountHandling.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
const signup = document.getElementById("signup")
const signupSection = document.querySelector(".signup")
const signup2 = document.getElementById("signup2")
const login = document.getElementById("login")
const loginSection = document.querySelector(".login")
const afterLoginSection = document.querySelector(".afterLogin")
const logOut = document.getElementById("signOut")
const Username = document.getElementById("name")
const email1 = document.getElementById("email1")
const passwordOne = document.getElementById("password1")
const passwordTwo = document.getElementById("password2")
const form1 = document.getElementById("form")
const emailTwo = document.getElementById("email2")
const passwordThree = document.getElementById("password3")
const auth = firebase.auth()
const Logo = document.querySelector("#logo")
// console.log(logo)
Logo.addEventListener("click", () => {
window.location.assign("index.html")
})
auth.onAuthStateChanged(user => {
// if (user) {
// }
// console.log(user)
})
function signUpFunction() {
email1Value = email1.value
passwordOneValue = passwordOne.value
passwordTwoValue = passwordTwo.value
// console.log(email1Value, passwordOneValue, passwordTwoValue)
if (passwordOneValue === passwordTwoValue) {
auth.createUserWithEmailAndPassword(email1Value, passwordOneValue)
.then(() => {
// console.log("success")
// window.location.assign("index.html")
// window.location.reload()
emailVerificationFunction()
// window.location.reload()
}).catch((e) => {
signupSection.classList.remove("active")
console.log(e)
})
}
}
const loginFunction = () => {
emailTwoValue = emailTwo.value
passwordThreeValue = passwordThree.value
// console.log(emailTwoValue, passwordThreeValue)
auth.signInWithEmailAndPassword(emailTwoValue, passwordThreeValue)
.then(() => {
// userEmail.innerHTML = emailTwoValue
// console.log("you are in")
// afterLoginSection.classList.remove("active")
// loginSection.classList.add("active")
window.location.replace("afterLoginPage.html")
// console.log("succsess")
}).catch((e) => {
console.log(e)
})
}
function emailVerificationFunction() {
auth.currentUser.sendEmailVerification()
.then(() => {
window.location.assign("index.html")
})
.catch((e) => {
console.log(e)
})
}
signup2.addEventListener("click", () => {
signupSection.classList.remove("active")
loginSection.classList.add("active")
})
signup.addEventListener("click", (e) => {
e.preventDefault()
signupSection.classList.add("active")
signUpFunction()
localStorage.removeItem("color")
let getColor1 = JSON.parse(localStorage.getItem("color"))
console.log(getColor1)
})
// logOut.addEventListener("click", () => {
// // loginSection.classList.remove("active")
// logOutFunction()
// window.location.reload()
// //
// })
login.addEventListener("click", loginFunction)