javascriptfirebasepolymerpolymer-1.0polymerfire

Firebase Polymer Anonymous authentication to google authentication


I've been watching Michael Bleigh on the polymer summit

when I try the

observers: ['autoAuth(user, statusKnown)],

autoAuth: function(user, statusKnown) {
  if(statusKnown && !user) {
    this.$.auth.signInAnonymously(); } 
},


signIn: function() {
  let google = new firebase.auth.GoogleAuthProvider();
  this.user.linkWithPopup(google);
}

It works just fine on a new user but on an old user I get the error that the credentials are already in use by another account

How do I solve this


Solution

  • Try this...

    observers: ['autoAuth(user, statusKnown)],
    
    autoAuth: function(user, statusKnown) {
      if(statusKnown && (user === null || Object.keys(user).length === 0)) {
        this.$.auth.signInAnonymously(); } 
    },
    
    
    signIn: function() {
      let google = new firebase.auth.GoogleAuthProvider();
      this.user.linkWithPopup(google);
    }