Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions templates/assets/firebase-check-login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
initApp = function() {
firebase.auth().onAuthStateChanged(function(user, o, i) {
if (user) {
if (window.location.pathname == '/' || window.location.pathname == '/index.html')
window.location.href='/home.html'
// console.log(user)
// var displayName = user.displayName
// var email = user.email
// var emailVerified = user.emailVerified
// var photoURL = user.photoURL
// var uid = user.uid
// var providerData = user.providerData
// user.getToken().then(function(accessToken) {
// document.getElementById('sign-in-status').textContent = 'Signed in'
// document.getElementById('sign-in').textContent = 'Sign out'
// document.getElementById('account-details').textContent = JSON.stringify({
// displayName: displayName,
// email: email,
// emailVerified: emailVerified,
// photoURL: photoURL,
// uid: uid,
// accessToken: accessToken,
// providerData: providerData
// }, null, ' ')
// })
} else if(window.location.pathname != '/index.html' && window.location.pathname != '/'){
// User is signed out.
// console.log('redirect to /')
window.location.href='/index.html'
}
}, function(error) {
console.log(error)
})
}

window.addEventListener('load', function() {
initApp()
})
10 changes: 10 additions & 0 deletions templates/assets/firebase-init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Initialize Firebase
var config = {
apiKey: "AIzaSyA7PHmaT1CsQOqJu26kfxJRcn-GBueITj8",
authDomain: "fox-developers.firebaseapp.com",
databaseURL: "https://fox-developers.firebaseio.com",
projectId: "fox-developers",
storageBucket: "fox-developers.appspot.com",
messagingSenderId: "1016773799220"
};
firebase.initializeApp(config);
16 changes: 16 additions & 0 deletions templates/assets/firebase-login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// FirebaseUI config.
var uiConfig = {
signInSuccessUrl: '/home.html',
signInOptions: [
// Leave the lines as is for the providers you want to offer your users.
firebase.auth.GoogleAuthProvider.PROVIDER_ID,
firebase.auth.EmailAuthProvider.PROVIDER_ID
],
// Terms of service url.
tosUrl: '/home.html'
};

// Initialize the FirebaseUI Widget using Firebase.
var ui = new firebaseui.auth.AuthUI(firebase.auth());
// The start method will wait until the DOM is loaded.
ui.start('#firebaseui-auth-container', uiConfig);
8 changes: 7 additions & 1 deletion templates/triple.jade
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@ html
meta(charset="utf-8")
title= self.api.name || 'API Documentation'
link(rel="stylesheet", href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css")
script(src="https://www.gstatic.com/firebasejs/3.9.0/firebase.js")
script(src="https://cdn.firebase.com/libs/firebaseui/1.0.1/firebaseui.js")
link(rel="stylesheet", href="https://cdn.firebase.com/libs/firebaseui/1.0.1/firebaseui.css")
script(src="/assets/firebase-init.js")
script(src="/assets/firebase-login.js")
script(src="/assets/firebase-check-login.js")
style!= self.css
body.preload

#nav-background
div.container-fluid.triple
.row
Expand All @@ -28,7 +35,6 @@ html
|  on #{self.date().format('DD MMM YYYY')}

script: include scripts.js

if self.livePreview
script(src="/socket.io/socket.io.js")
script.
Expand Down