From bd438b4f3fc6a20a2121d5754783003253b7b0b7 Mon Sep 17 00:00:00 2001 From: Nicolas Garnier Date: Wed, 28 Mar 2018 13:48:30 +0200 Subject: [PATCH] Automatically reset the firebaseUI instance when the user signs-out. --- src/FirebaseAuth.jsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/FirebaseAuth.jsx b/src/FirebaseAuth.jsx index 807aef96..d120f473 100644 --- a/src/FirebaseAuth.jsx +++ b/src/FirebaseAuth.jsx @@ -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);