so I'm trying to build a nice multi-tabbed login form using polymer and the <firebase-login>
element. It looks something like this: https://ele.io/caseybaggz/paper-form
One one tab, I have some social login buttons (google, twitter, fb), on the other, email/password login/register. I'm also using <app-router>
on my index.html
to route all my views(elements), and the <pvc-globals>
to hold global objects. So, when user's are logged in, they are routed to a new element. Here is the login code:
login: function() {
if (debug) {
console.log('Logging in');
console.log('loginProvider: ' + this.$.login.provider);
console.log('loginUser: ' + this.$.login.user);
console.log('global.currentUser: ' + this.globals.currentUser);
}
var params;
try {
params = JSON.parse(document.querySelector("#params").value);
} catch (e) {
params = null;
}
if (this.provider == 'password') {
params = this.params || {};
params.email = this.email;
params.password = this.userPassword;
}
this.globals.currentUser = this.user;
this.$.login.login(params);
// If login successful
window.location.href = "#/home";
},
It's basically the same thing that the firebase demo gives.
So, for some reason, I can log people in successfully, but when I console the firebase user
object, it returns null
. Also, the login function is re-routing people faster than firebase is logging user's in with the social buttons.
My main question: Why is firebase saying the user object is null after a successful login? The second part of that would be how to re-route users AFTER the login takes it's course?
Thanks in advance!
I recommend that you use the "real" api instead of the firebase-login wrapper. In your case I'm guessing https://www.firebase.com/docs/web/api/firebase/authwithoauthpopup.html And do the redirect in the callback from the auth method. Same with settings the globals value.
OR
You can define a on-login function on the firebase-login and do the redirect and setting globals value in that function.