From 720422c65de5e1fa4c222acef78a5e0bbecfa25d Mon Sep 17 00:00:00 2001 From: Ilya Oleshko Date: Wed, 28 Aug 2024 13:33:25 +0300 Subject: [PATCH] Fixed Bug 67513: Client: Added authorized flag for download operation page --- packages/client/src/pages/Confirm/sub-components/auth.js | 6 +++++- .../operation-container/OperationContainer.types.ts | 1 + packages/shared/components/operation-container/index.tsx | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/client/src/pages/Confirm/sub-components/auth.js b/packages/client/src/pages/Confirm/sub-components/auth.js index 8c50e80aff..4a97cae98b 100644 --- a/packages/client/src/pages/Confirm/sub-components/auth.js +++ b/packages/client/src/pages/Confirm/sub-components/auth.js @@ -24,7 +24,7 @@ // content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode -import React, { useEffect } from "react"; +import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { Loader } from "@docspace/shared/components/loader"; import Section from "@docspace/shared/components/section"; @@ -42,6 +42,8 @@ const Auth = (props) => { let [searchParams, setSearchParams] = useSearchParams(); const { t } = useTranslation(["Common"]); + const [authorized, setAuthorized] = useState(false); + const referenceUrl = searchParams.get("referenceUrl"); const isFileHandler = referenceUrl && referenceUrl.indexOf("filehandler.ashx") !== -1; @@ -63,6 +65,7 @@ const Auth = (props) => { try { new URL(referenceUrl); if (isFileHandler && isExternalDownloading) { + setAuthorized(true); return; } else { return window.location.replace(referenceUrl); @@ -86,6 +89,7 @@ const Auth = (props) => { return isFileHandler && isExternalDownloading ? ( diff --git a/packages/shared/components/operation-container/OperationContainer.types.ts b/packages/shared/components/operation-container/OperationContainer.types.ts index 47e1dba80a..a1d87d74ed 100644 --- a/packages/shared/components/operation-container/OperationContainer.types.ts +++ b/packages/shared/components/operation-container/OperationContainer.types.ts @@ -26,6 +26,7 @@ export interface IOperationContainer { url?: string; + authorized: boolean; title: string; description: string; } diff --git a/packages/shared/components/operation-container/index.tsx b/packages/shared/components/operation-container/index.tsx index a91bace8ef..81312ab86f 100644 --- a/packages/shared/components/operation-container/index.tsx +++ b/packages/shared/components/operation-container/index.tsx @@ -35,7 +35,7 @@ import { Text } from "../text"; import PortalLogo from "../portal-logo/PortalLogo"; const OperationContainer = (props: IOperationContainer) => { - const { url, title, description } = props; + const { url, authorized, title, description } = props; const theme = useTheme(); @@ -46,8 +46,8 @@ const OperationContainer = (props: IOperationContainer) => { ); useEffect(() => { - if (url) window.location.replace(url); - }, [url]); + if (url && authorized) window.location.replace(url); + }, [url, authorized]); return (