Skip to content

Commit bd77aed

Browse files
authored
Throw Operation Not Allowed Exception in FirebaseAuthInterop getUid for… (#9325)
* Throw UnsupportedOperationException in FirebaseAuthInterop getUid for regionalAuth * yarn run format * Updating the chrome_validated_version for tests * Address comments
1 parent b27267f commit bd77aed

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

.github/workflows/test-all.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ env:
2323
# the behavior to use the new URLs.
2424
CHROMEDRIVER_CDNURL: https://googlechromelabs.github.io/
2525
CHROMEDRIVER_CDNBINARIESURL: https://storage.googleapis.com/chrome-for-testing-public
26-
CHROME_VALIDATED_VERSION: linux-132.0.6834.110
26+
CHROME_VALIDATED_VERSION: linux-141.0.7390.78
2727
CHROME_VERSION_MISMATCH_MESSAGE: "The Chrome version doesn't match the previously validated version. Consider updating CHROME_VALIDATED_VERSION in the GitHub workflow if tests pass, or rollback the installed Chrome version if tests fail."
2828
artifactRetentionDays: 14
2929
# Bump Node memory limit

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('throws an error if regionalAuth is initialized', () => {
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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ export class AuthInterop implements FirebaseAuthInternal {
3636

3737
getUid(): string | null {
3838
this.assertAuthConfigured();
39+
// getUid() is not available for regional Auth. Returns `OPERATION_NOT_ALLOWED` exception for RegionalAuth.
40+
this.assertRegionalAuthConfigured();
3941
return this.auth.currentUser?.uid || null;
4042
}
4143

@@ -90,6 +92,10 @@ export class AuthInterop implements FirebaseAuthInternal {
9092
);
9193
}
9294

95+
private assertRegionalAuthConfigured(): void {
96+
_assert(!this.auth.tenantConfig, AuthErrorCode.OPERATION_NOT_ALLOWED);
97+
}
98+
9399
private updateProactiveRefresh(): void {
94100
if (this.internalListeners.size > 0) {
95101
this.auth._startProactiveRefresh();

0 commit comments

Comments
 (0)