-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.js
48 lines (40 loc) · 1.51 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
function createUser() {
var email = document.getElementById("userEmail").value;
var password = document.getElementById("userPassword").value;
var confirmPassword = document.getElementById("confirmPassword").value;
console.log(password);
console.log(confirmPassword);
//validate that both passwords are same
if (password == confirmPassword) {
//Here we will write create Account code
//firebase has its own built in create account method
//lets start
//it takes two param first one email and second is password
firebase.auth().createUserWithEmailAndPassword(email, password).then(
function() {
//this function executes when account is successfully created
window.location = "login.html";
}).catch(function(error) {
//this function handles errors
var errorMessage = error.message;
alert(errorMessage);
});
} else {
//alert when password did not matches
alert("password does not matches");
}
}
// function storeUser(){
// var name, password;
// function Ready() {
// name = document.getElementById('userName').value;
// password = document.getElementById('userPassword').value;
// }
// document.getElementById('insert').onclick = function() {
// Ready();
// firebase.database().ref('users/' + name).set({
// Name: name,
// Password: password
// })
// }
// }