forked from cdanis/urzas-overlay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
firebase.js
31 lines (26 loc) · 903 Bytes
/
firebase.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
// Initialize Firebase
firebase.initializeApp(config);
function signIn() {
firebase.auth().signInWithRedirect(new firebase.auth.GoogleAuthProvider());
}
function signOut() {
firebase.auth().signOut();
}
$(function () {
firebase.auth().onAuthStateChanged(function (user) {
if (user) {
var profilePicUrl = user.photoURL;
if (!profilePicUrl && user.providerData && user.providerData.length > 0) {
profilePicUrl = user.providerData[0].photoURL;
}
$("#user-pic").css("background-image", 'url(' + profilePicUrl + ')');
$("#user-pic, #sign-out").show();
$("#sign-in").hide();
} else { // User is signed out!
$("#user-name, #user-pic, #sign-out").hide();
$("#sign-in").show();
}
});
$("#sign-out").click(signOut);
$("#sign-in").click(signIn);
});