File tree 2 files changed +8
-6
lines changed
2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -82,8 +82,9 @@ export class AuthImpl implements Auth, _FirebaseService {
82
82
readonly name : string ;
83
83
84
84
// Tracks the last notified UID for state change listeners to prevent
85
- // repeated calls to the callbacks
86
- private lastNotifiedUid : string | undefined = undefined ;
85
+ // repeated calls to the callbacks. Undefined means it's never been
86
+ // called, whereas null means it's been called with a signed out user
87
+ private lastNotifiedUid : string | null | undefined = undefined ;
87
88
88
89
languageCode : string | null = null ;
89
90
tenantId : string | null = null ;
@@ -474,8 +475,9 @@ export class AuthImpl implements Auth, _FirebaseService {
474
475
475
476
this . idTokenSubscription . next ( this . currentUser ) ;
476
477
477
- if ( this . lastNotifiedUid !== this . currentUser ?. uid ) {
478
- this . lastNotifiedUid = this . currentUser ?. uid ;
478
+ const currentUid = this . currentUser ?. uid ?? null ;
479
+ if ( this . lastNotifiedUid !== currentUid ) {
480
+ this . lastNotifiedUid = currentUid ;
479
481
this . authStateSubscription . next ( this . currentUser ) ;
480
482
}
481
483
}
Original file line number Diff line number Diff line change @@ -267,7 +267,7 @@ export interface Auth {
267
267
* @param completed - callback triggered when observer is removed.
268
268
*/
269
269
onAuthStateChanged (
270
- nextOrObserver : NextOrObserver < User > ,
270
+ nextOrObserver : NextOrObserver < User | null > ,
271
271
error ?: ErrorFn ,
272
272
completed ?: CompleteFn
273
273
) : Unsubscribe ;
@@ -282,7 +282,7 @@ export interface Auth {
282
282
* @param completed - callback triggered when observer is removed.
283
283
*/
284
284
onIdTokenChanged (
285
- nextOrObserver : NextOrObserver < User > ,
285
+ nextOrObserver : NextOrObserver < User | null > ,
286
286
error ?: ErrorFn ,
287
287
completed ?: CompleteFn
288
288
) : Unsubscribe ;
You can’t perform that action at this time.
0 commit comments