Skip to content

Commit

Permalink
Automatically reset the firebaseUI instance when the user signs-out.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Garnier committed Mar 28, 2018
1 parent b9c7599 commit bd438b4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/FirebaseAuth.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ export default class FirebaseAuth extends React.Component {
this.firebaseUiWidget.reset();
}

// We track the auth state to reset firebaseUi if the user signs out.
this.userSignedIn = false;
this.unregisterAuthObserver = this.firebaseAuth.onAuthStateChanged((user) => {
if (!user && this.userSignedIn) {
this.firebaseUiWidget.reset();
}
this.userSignedIn = !!user;
});

// Trigger the callback if any was set.
if (this.uiCallback) {
this.uiCallback(this.firebaseUiWidget);
Expand Down

0 comments on commit bd438b4

Please sign in to comment.