From 4d0b1a6db8256a742cc6ad182094dd1a60543129 Mon Sep 17 00:00:00 2001 From: jawelton74 <103591340+jawelton74@users.noreply.github.com> Date: Tue, 18 Jun 2024 09:41:24 -0700 Subject: [PATCH] Switch accountrestrictions call to use new backend in MPAC. (#1868) --- src/Common/Constants.ts | 1 + src/Platform/Hosted/Components/ConnectExplorer.tsx | 9 +++++++-- src/Utils/EndpointUtils.ts | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Common/Constants.ts b/src/Common/Constants.ts index ff121f3a5..cb4c8f007 100644 --- a/src/Common/Constants.ts +++ b/src/Common/Constants.ts @@ -133,6 +133,7 @@ export enum MongoBackendEndpointType { export class BackendApi { public static readonly GenerateToken: string = "GenerateToken"; public static readonly PortalSettings: string = "PortalSettings"; + public static readonly AccountRestrictions: string = "AccountRestrictions"; } export class PortalBackendEndpoints { diff --git a/src/Platform/Hosted/Components/ConnectExplorer.tsx b/src/Platform/Hosted/Components/ConnectExplorer.tsx index 513247a6c..64f8540b7 100644 --- a/src/Platform/Hosted/Components/ConnectExplorer.tsx +++ b/src/Platform/Hosted/Components/ConnectExplorer.tsx @@ -51,13 +51,18 @@ export const fetchEncryptedToken_ToBeDeprecated = async (connectionString: strin export const isAccountRestrictedForConnectionStringLogin = async (connectionString: string): Promise => { const headers = new Headers(); headers.append(HttpHeaders.connectionString, connectionString); - const url = configContext.BACKEND_ENDPOINT + "/api/guest/accountrestrictions/checkconnectionstringlogin"; + + const backendEndpoint: string = useNewPortalBackendEndpoint(BackendApi.PortalSettings) + ? configContext.PORTAL_BACKEND_ENDPOINT + : configContext.BACKEND_ENDPOINT; + + const url = backendEndpoint + "/api/guest/accountrestrictions/checkconnectionstringlogin"; const response = await fetch(url, { headers, method: "POST" }); if (!response.ok) { throw response; } - return (await response.text()) === "True"; + return (await response.text()).toLowerCase() === "true"; }; export const ConnectExplorer: React.FunctionComponent = ({ diff --git a/src/Utils/EndpointUtils.ts b/src/Utils/EndpointUtils.ts index 97e733b98..b685dc71a 100644 --- a/src/Utils/EndpointUtils.ts +++ b/src/Utils/EndpointUtils.ts @@ -164,6 +164,7 @@ export function useNewPortalBackendEndpoint(backendApi: string): boolean { PortalBackendEndpoints.Mpac, PortalBackendEndpoints.Prod, ], + [BackendApi.AccountRestrictions]: [PortalBackendEndpoints.Development, PortalBackendEndpoints.Mpac], }; if (!newBackendApiEnvironmentMap[backendApi] || !configContext.PORTAL_BACKEND_ENDPOINT) {