-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathregistration.js
36 lines (30 loc) · 1.01 KB
/
registration.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
console.log("running registration.js")
import{ getAuth, onAuthStateChanged, createUserWithEmailAndPassword, sendEmailVerification} from "https://www.gstatic.com/firebasejs/10.5.0/firebase-auth.js";
const auth = getAuth();
console.log(auth)
const signUpBtn = document.querySelector(".signup-btn")
console.log(signUpBtn)
document.getElementById("signUpForm").addEventListener("submit", (e)=> {
e.preventDefault()
})
onAuthStateChanged(auth, (user)=> {
if(user){
//alert("registered")
//location.replace("index.html")
}
})
const signUpClicked = ()=>{
const email= document.getElementById("email").value;
const password = document.getElementById("password").value;
createUserWithEmailAndPassword(auth, email, password)
.then((userCredentials)=>{
sendEmailVerification(auth.currentUser)
.then(()=>{
alert("Email Verification link sent")
})
})
.catch((error=>{
alert(error)
}))
}
signUpBtn.addEventListener("click", signUpClicked)