-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.js
60 lines (55 loc) · 1.81 KB
/
main.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
var firebaseConfig = {
apiKey: "AIzaSyDOl8jUOlj3E2vf7feuELRM4tj9Y70kBSA",
authDomain: "lahacks-70de2.firebaseapp.com",
databaseURL: "https://lahacks-70de2.firebaseio.com",
projectId: "lahacks-70de2",
storageBucket: "lahacks-70de2.appspot.com",
messagingSenderId: "724684122347",
appId: "1:724684122347:web:5619f60fde8aa057daf6ae",
measurementId: "G-TW1G530C4H"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics();
firebase.auth().onAuthStateChanged(user => {
if (user) {
window.location.href = '../main.html';
}
});
var provider = new firebase.auth.GoogleAuthProvider();
function signUpWithGoogle() {
console.log('hi');
firebase.auth().signInWithPopup(provider).then(function(result) {
// This gives you a Google Access Token. You can use it to access the Google API.
var token = result.credential.accessToken;
// The signed-in user info.
var user = result.user;
// ...
}).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// The email of the user's account used.
var email = error.email;
// The firebase.auth.AuthCredential type that was used.
var credential = error.credential;
// ...
});
}
// user/photos
function uploadData() {
var user = firebase.auth().currentUser;
var uid = user.uid;
var storageRef = firebase.storage().ref();
var userRef = storageRef.child(uid);
var file = new File();
userRef.put(file).then(function(snapshot) {
console.log('file uploaded');
});
}
function getData() {
var user = firebase.auth().currentUser;
var uid = user.uid;
var storageRef = firebase.storage.ref();
var userRef = storageRef.child(uid);
}