-
Notifications
You must be signed in to change notification settings - Fork 0
/
form.js
41 lines (40 loc) · 1.18 KB
/
form.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
var firebaseConfig = {
apiKey:"AIzaSyAC7IU-swlsA1fMTveq66_4uXWVo3-R12I",
authDomain:"advocacy-app-20907.firebaseapp.com",
databaseURL:"https://advocacy-app-20907.firebaseio.com",
projectId:"advocacy-app-20907",
storageBucket:"advocacy-app-20907.appspot.com",
messagingSenderId:"88488987094",
appId:"1:88488987094:web:0545bd16011f58f9c93c77"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
const auth = firebase.auth();
function signUp(){
var email = document.getElementById("email");
var password = document.getElementById("password");
const promise = auth.createUserWithEmailAndPassword(email.value, password.value);
promise.catch(e => alert(e.message));
alert("Signed Up");
}
function signIn(){
var email = document.getElementById("email");
var password = document.getElementById("password");
const promise = auth.signInWithEmailAndPassword(email.value, password.value);
promise.catch(e => alert(e.message));
}
function signOut(){
auth.signOut();
alert("Signed Out");
}
auth.onAuthStateChanged(function(user){
if(user){
var email = user.email;
alert("Active User " + email);
//Take user to a different or home page
//is signed in
}else{
alert("No Active User");
//no user is signed in
}
});