Skip to content

Commit d579f39

Browse files
committed
Throw UnsupportedOperationException in FirebaseAuthInterop getUid for regionalAuth
1 parent b27267f commit d579f39

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

packages/auth/src/core/auth/firebase_internal.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,4 +326,13 @@ describe('core/auth/firebase_internal - Regional Firebase Auth', () => {
326326
expect(await regionalAuthInternal.getToken()).to.eql(null);
327327
});
328328
});
329+
330+
context('getUid', () => {
331+
it('returns null if currentUser is undefined', () => {
332+
expect(() => regionalAuthInternal.getUid()).to.throw(
333+
FirebaseError,
334+
'auth/operation-not-allowed'
335+
);
336+
});
337+
});
329338
});

packages/auth/src/core/auth/firebase_internal.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export class AuthInterop implements FirebaseAuthInternal {
3636

3737
getUid(): string | null {
3838
this.assertAuthConfigured();
39+
this.assertRegionalAuthConfigured();
3940
return this.auth.currentUser?.uid || null;
4041
}
4142

@@ -90,6 +91,13 @@ export class AuthInterop implements FirebaseAuthInternal {
9091
);
9192
}
9293

94+
95+
private assertRegionalAuthConfigured(): void {
96+
_assert(
97+
!this.auth.tenantConfig,
98+
AuthErrorCode.OPERATION_NOT_ALLOWED);
99+
}
100+
93101
private updateProactiveRefresh(): void {
94102
if (this.internalListeners.size > 0) {
95103
this.auth._startProactiveRefresh();

0 commit comments

Comments
 (0)