Skip to content

Commit bc2e5ba

Browse files
committed
Fix callbacks not getting updated #81
1 parent 3c53ad1 commit bc2e5ba

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

projects/firebaseui-angular-library/src/lib/firebaseui-angular-library.component.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import UserCredential = firebase.auth.UserCredential;
3131
template: '<div id="firebaseui-auth-container"></div>'
3232
})
3333
export class FirebaseuiAngularLibraryComponent implements OnInit, OnDestroy {
34+
private static readonly COMPUTED_CALLBACKS = 'COMPUTED_CALLBACKS';
3435

3536
/**
3637
* @deprecated Use signInSuccessWithAuthResult
@@ -97,6 +98,7 @@ export class FirebaseuiAngularLibraryComponent implements OnInit, OnDestroy {
9798
private getUIAuthConfig(): NativeFirebaseUIAuthConfig {
9899
if (!(this.firebaseUiConfig as FirebaseUIAuthConfig).providers) {
99100
if (!(this.firebaseUiConfig as NativeFirebaseUIAuthConfig).callbacks) {
101+
this.firebaseUiConfig[FirebaseuiAngularLibraryComponent.COMPUTED_CALLBACKS] = true;
100102
(this.firebaseUiConfig as NativeFirebaseUIAuthConfig).callbacks = this.getCallbacks();
101103
}
102104
return (this.firebaseUiConfig as NativeFirebaseUIAuthConfig);
@@ -185,7 +187,22 @@ export class FirebaseuiAngularLibraryComponent implements OnInit, OnDestroy {
185187

186188
private firebaseUIPopup() {
187189
const firebaseUiInstance = this.firebaseUIService.firebaseUiInstance;
188-
firebaseUiInstance.start('#firebaseui-auth-container', this.getUIAuthConfig());
190+
const uiAuthConfig = this.getUIAuthConfig();
191+
192+
// Check if callbacks got computed to reset them again after providing the to firebaseui.
193+
// Necessary for allowing updating the firebaseui config during runtime.
194+
let resetCallbacks = false;
195+
if (uiAuthConfig[FirebaseuiAngularLibraryComponent.COMPUTED_CALLBACKS]) {
196+
resetCallbacks = true;
197+
delete uiAuthConfig[FirebaseuiAngularLibraryComponent.COMPUTED_CALLBACKS];
198+
}
199+
200+
// show the firebaseui
201+
firebaseUiInstance.start('#firebaseui-auth-container', uiAuthConfig);
202+
203+
if (resetCallbacks) {
204+
(this.firebaseUiConfig as NativeFirebaseUIAuthConfig).callbacks = null;
205+
}
189206
}
190207

191208
private getCallbacks(): any {

0 commit comments

Comments
 (0)