Dear, I'm testing how firebase authentication works, I can authenticate anyway (Github, FB, Twitter, Google) but I can only use result data on the home page. I would like to know how I could open another tab and be able to use the firebase return data, because the data in my result is only available on the start page. So I try to open a tab using window.location.href but I do not know if it is possible to pass the result data.
HTML home page (index.html)
<button id="authGitHubButton">
Log in with GitHub
</button>
Javascript
// Autenticar com GitHub
var authGitHubButton = document.getElementById('authGitHubButton');
authGitHubButton.addEventListener('click', function () {
// Providers
var provider = new firebase.auth.GithubAuthProvider();
window.location.href = "/access.html";
signIn(provider);
});
function signIn(provider) {
firebase.auth()
.signInWithPopup(provider)
.then(function (result) {
console.log(result);
var token = result.credential.accessToken;
displayName.innerText = 'Ola, ' + result.user.displayName;
photoURL.setAttribute("src", result.user.photoURL);
photoURL.style.display = 'block';
}).catch(function (error) {
console.log(error);
alert('Falha na autenticação');
});
}
New HTML tab (access.html)
<h3 id="displayName"></h3>
<img class="photoURL text-center image-responsive" id="photoURL" src=""></img>