-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.js
34 lines (29 loc) · 871 Bytes
/
config.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
// Initialize Firebase
var config = {
apiKey: "AIzaSyCN6LlN56EbTHeNwPoV8hfNhmZmKojd2OE",
authDomain: "scarf-pattern-generator.firebaseapp.com",
databaseURL: "https://scarf-pattern-generator.firebaseio.com",
projectId: "scarf-pattern-generator",
storageBucket: "scarf-pattern-generator.appspot.com",
messagingSenderId: "46984582340"
};
firebase.initializeApp(config);
var db = firebase.firestore();
var user;
firebase.auth().onAuthStateChanged(function(u) {
if (u) {
// User is signed in.
user = u;
} else {
// No user is signed in.
console.log("no user");
signInAnonymously();
}
});
function signInAnonymously(){
firebase.auth().signInAnonymously().catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
});
}