diff --git a/src/Platform/Hosted/Components/ConnectExplorer.tsx b/src/Platform/Hosted/Components/ConnectExplorer.tsx index 3ee72246e..624137030 100644 --- a/src/Platform/Hosted/Components/ConnectExplorer.tsx +++ b/src/Platform/Hosted/Components/ConnectExplorer.tsx @@ -30,6 +30,18 @@ export const fetchEncryptedToken = async (connectionString: string): Promise => { + const headers = new Headers(); + headers.append(HttpHeaders.connectionString, connectionString); + const url = configContext.BACKEND_ENDPOINT + "/api/guest/accountrestrictions/checkconnectionstringlogin"; + const response = await fetch(url, { headers, method: "POST" }); + if (!response.ok) { + throw response; + } + + return (await response.text()) === "True"; +}; + export const ConnectExplorer: React.FunctionComponent = ({ setEncryptedToken, login, @@ -38,6 +50,7 @@ export const ConnectExplorer: React.FunctionComponent = ({ setConnectionString, }: Props) => { const [isFormVisible, { setTrue: showForm }] = useBoolean(false); + const [errorMessage, setErrorMessage] = React.useState(""); const enableConnectionStringLogin = !userContext.features.disableConnectionStringLogin; return ( @@ -53,6 +66,12 @@ export const ConnectExplorer: React.FunctionComponent = ({ id="connectWithConnectionString" onSubmit={async (event) => { event.preventDefault(); + setErrorMessage(""); + + if (await isAccountRestrictedForConnectionStringLogin(connectionString)) { + setErrorMessage("This account has been blocked from connection-string login."); + return; + } if (isResourceTokenConnectionString(connectionString)) { setAuthType(AuthType.ResourceToken); @@ -76,10 +95,12 @@ export const ConnectExplorer: React.FunctionComponent = ({ setConnectionString(event.target.value); }} /> - - Error notification - - + {errorMessage.length > 0 && ( + + Error notification + {errorMessage} + + )}