Skip to content

Commit 6583820

Browse files
committed
update registerStateListener logic
1 parent 2ad4ad4 commit 6583820

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

packages/auth/src/core/auth/auth_impl.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,6 @@ export class AuthImpl implements AuthInternal, _FirebaseService {
647647
return this.registerStateListener(
648648
this.authStateSubscription,
649649
nextOrObserver,
650-
this.currentUser,
651650
error,
652651
completed
653652
);
@@ -668,7 +667,6 @@ export class AuthImpl implements AuthInternal, _FirebaseService {
668667
return this.registerStateListener(
669668
this.idTokenSubscription,
670669
nextOrObserver,
671-
this.currentUser,
672670
error,
673671
completed
674672
);
@@ -682,7 +680,6 @@ export class AuthImpl implements AuthInternal, _FirebaseService {
682680
return this.registerStateListener(
683681
this.firebaseTokenSubscription,
684682
nextOrObserver,
685-
this.firebaseToken,
686683
error,
687684
completed
688685
);
@@ -833,7 +830,6 @@ export class AuthImpl implements AuthInternal, _FirebaseService {
833830
private registerStateListener<T>(
834831
subscription: Subscription<T>,
835832
nextOrObserver: NextOrObserver<T>,
836-
currentValue: T | null,
837833
error?: ErrorFn,
838834
completed?: CompleteFn
839835
): Unsubscribe {
@@ -858,7 +854,14 @@ export class AuthImpl implements AuthInternal, _FirebaseService {
858854
if (isUnsubscribed) {
859855
return;
860856
}
861-
cb(currentValue);
857+
if (
858+
(subscription as unknown) === this.idTokenSubscription ||
859+
(subscription as unknown) === this.authStateSubscription
860+
) {
861+
cb(this.currentUser as unknown as T);
862+
} else if ((subscription as unknown) === this.firebaseTokenSubscription) {
863+
cb(this.firebaseToken as unknown as T);
864+
}
862865
});
863866

864867
if (typeof nextOrObserver === 'function') {

0 commit comments

Comments
 (0)