Demo.prototype.onAuthStateChanged = function()

in email-confirmation/public/main.js [40:67]


Demo.prototype.onAuthStateChanged = function(user) {
  if (user) {
    this.nameContainer.innerText = user.displayName;
    this.emailContainer.innerText = user.email;
    this.signedOutCard.style.display = 'none';
    this.signedInCard.style.display = 'block';
    this.userRef = firebase.database().ref('users/' + user.uid);
    this.userRef.on('value', function(data) {
      if (data.val() && data.val().subscribedToMailingList) {
        this.subscribedTextContainer.style.display = 'block';
        this.unsubscribedTextContainer.style.display = 'none';
        this.subscribeButton.style.display = 'none';
        this.unsubscribeButton.style.display = 'inline-block';
      } else {
        this.subscribedTextContainer.style.display = 'none';
        this.unsubscribedTextContainer.style.display = 'block';
        this.subscribeButton.style.display = 'inline-block';
        this.unsubscribeButton.style.display = 'none';
      }
    }.bind(this));
  } else {
    if (this.userRef) {
      this.userRef.off();
    }
    this.signedOutCard.style.display = 'block';
    this.signedInCard.style.display = 'none';
  }
};