Skip to content

Commit bd438b4

Browse files
author
Nicolas Garnier
committed
Automatically reset the firebaseUI instance when the user signs-out.
1 parent b9c7599 commit bd438b4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/FirebaseAuth.jsx

+9
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ export default class FirebaseAuth extends React.Component {
6363
this.firebaseUiWidget.reset();
6464
}
6565

66+
// We track the auth state to reset firebaseUi if the user signs out.
67+
this.userSignedIn = false;
68+
this.unregisterAuthObserver = this.firebaseAuth.onAuthStateChanged((user) => {
69+
if (!user && this.userSignedIn) {
70+
this.firebaseUiWidget.reset();
71+
}
72+
this.userSignedIn = !!user;
73+
});
74+
6675
// Trigger the callback if any was set.
6776
if (this.uiCallback) {
6877
this.uiCallback(this.firebaseUiWidget);

0 commit comments

Comments
 (0)