'use strict'; window.addEventListener('load', function () { var uiConfig = { signInSuccessUrl: '/', signInOptions: [ //firebase.auth.GoogleAuthProvider.PROVIDER_ID, firebase.auth.EmailAuthProvider.PROVIDER_ID, ], tosUrl: '' }; firebase.auth().onAuthStateChanged(function (user) { if (user) { // User is signed in, so display the "sign out" button and login info. console.log(`Signed in as ${user.displayName} (${user.email})`); user.getIdToken().then(function (token) { document.cookie = "token=" + token; if (user.emailVerified) { window.location.href = "/project"; } else { window.location.href = "/verify"; } }); } else { var ui = new firebaseui.auth.AuthUI(firebase.auth()); ui.start('#firebaseui-auth-container', uiConfig); document.cookie = "token="; } }, function (error) { console.log(error); alert('Unable to log in: ' + error) }); });