-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.js
71 lines (52 loc) · 1.68 KB
/
signup.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
var firebaseConfig = {
apiKey: "AIzaSyDiAD9-E0JkSKt3BD5y5Gpj7OP5Cz1ZSbc",
authDomain: "officemanagement-3196a.firebaseapp.com",
databaseURL: "https://officemanagement-3196a.firebaseio.com",
projectId: "officemanagement-3196a",
storageBucket: "officemanagement-3196a.appspot.com",
messagingSenderId: "810522578256",
appId: "1:810522578256:web:6a05bc912515494b26f055",
measurementId: "G-ELCBHR461S"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics();
const db = firebase.firestore();
const txtemail = document.getElementById('txtemail');
const txtpassword = document.getElementById('txtpassword');
const button = document.getElementById('submit');
const txtname = document.getElementById('name');
const txtphone = document.getElementById('phone');
const txty =document.getElementById('again-password');
button.addEventListener('click', e=>{
if(txty.value===txtpassword.value)
{
const email = txtemail.value;
const password = txtpassword.value;
const name = txtname.value;
const phone = txtphone.value;
firebase.auth().createUserWithEmailAndPassword(email, password)
.catch(function (err) {
console.log(err)
alert(err)
}).then(db.collection("users").add({
name: name,
email: email,
phone: phone
})
.then(function(doc) {
console.log("Document written with ID: ", doc.id);
}).catch(function(err){
console.log(err)
}));
firebase.auth().onAuthStateChanged(user => {
if(user) {
window.location = './landing.html';
}
});
}
else
{
alert('ERROR Pls enter same password');
}
});