diff --git a/src/Platform/Hosted/Components/ConnectExplorer.tsx b/src/Platform/Hosted/Components/ConnectExplorer.tsx index 6e0fdd135..588ef778e 100644 --- a/src/Platform/Hosted/Components/ConnectExplorer.tsx +++ b/src/Platform/Hosted/Components/ConnectExplorer.tsx @@ -6,13 +6,8 @@ import ConnectImage from "../../../../images/HdeConnectCosmosDB.svg"; import ErrorImage from "../../../../images/error.svg"; import { AuthType } from "../../../AuthType"; import { AccessInputMetadata } from "../../../Contracts/DataModels"; -import { isAuthorizationError } from "../../../Utils/AuthorizationUtils"; import { parseConnectionString } from "../Helpers/ConnectionStringParser"; -import { - fetchEncryptedToken, - isAccountRestrictedForConnectionStringLogin, - PortalBackendError, -} from "../Helpers/PortalBackendClient"; +import { fetchEncryptedToken, isAccountRestrictedForConnectionStringLogin } from "../Helpers/PortalBackendClient"; import { isResourceTokenConnectionString } from "../Helpers/ResourceTokenUtils"; import { isDirectConnectionStringLoginApi } from "../HostedUtils"; @@ -78,22 +73,9 @@ export const ConnectExplorer: React.FunctionComponent = ({ return; } - try { - const encryptedToken = await fetchEncryptedToken(connectionString); - setEncryptedToken(encryptedToken); - setAuthType(AuthType.ConnectionString); - } catch (error) { - // A 401 or 403 means the credentials or Portal Backend were not authorized. - // Any other failure is on the backend, so rather than block the login - // we sign in with the metadata parsed from the connection string. - if (!metadata || (error instanceof PortalBackendError && isAuthorizationError(error.statusCode))) { - setErrorMessage(getErrorMessage(error)); - return; - } - - setAccountMetadata(metadata); - setAuthType(AuthType.ConnectionString); - } + const encryptedToken = await fetchEncryptedToken(connectionString); + setEncryptedToken(encryptedToken); + setAuthType(AuthType.ConnectionString); }} >

Connect to your account with connection string

diff --git a/src/Utils/AuthorizationUtils.test.ts b/src/Utils/AuthorizationUtils.test.ts index 6c9cb0f48..fd361ac22 100644 --- a/src/Utils/AuthorizationUtils.test.ts +++ b/src/Utils/AuthorizationUtils.test.ts @@ -76,22 +76,6 @@ describe("AuthorizationUtils", () => { }); }); - describe("isAuthorizationError()", () => { - it("should return true for 401 and 403", () => { - expect(AuthorizationUtils.isAuthorizationError(401)).toBe(true); - expect(AuthorizationUtils.isAuthorizationError(403)).toBe(true); - }); - - it("should return false for other statuses", () => { - expect(AuthorizationUtils.isAuthorizationError(404)).toBe(false); - expect(AuthorizationUtils.isAuthorizationError(500)).toBe(false); - }); - - it("should return false when there is no status", () => { - expect(AuthorizationUtils.isAuthorizationError(undefined)).toBe(false); - }); - }); - describe("decryptJWTToken()", () => { it("should throw an error if token is undefined", () => { expect(() => AuthorizationUtils.decryptJWTToken(undefined)).toThrow(); diff --git a/src/Utils/AuthorizationUtils.ts b/src/Utils/AuthorizationUtils.ts index 40048e241..0938c6f33 100644 --- a/src/Utils/AuthorizationUtils.ts +++ b/src/Utils/AuthorizationUtils.ts @@ -28,10 +28,6 @@ export function getAuthorizationHeader(): ViewModels.AuthorizationTokenHeaderMet } } -export function isAuthorizationError(statusCode: number): boolean { - return statusCode === Constants.HttpStatusCodes.Unauthorized || statusCode === Constants.HttpStatusCodes.Forbidden; -} - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types export function decryptJWTToken(token: string) { if (!token) {