diff --git a/live/src/ce/lib/authentication.ts b/live/src/ce/lib/authentication.ts index 291085e94..3d5a1ea48 100644 --- a/live/src/ce/lib/authentication.ts +++ b/live/src/ce/lib/authentication.ts @@ -4,14 +4,12 @@ import { TDocumentTypes } from "@/core/types/common.js"; type TArgs = { connection: ConnectionConfiguration - cookie: string | undefined; + cookie: string; + documentType: TDocumentTypes | undefined; params: URLSearchParams; } -export const authenticateUser = (args: TArgs): Promise => { - const { params } = args; - const documentType = params.get("documentType")?.toString() as - | TDocumentTypes - | undefined; +export const authenticateUser = async (args: TArgs): Promise => { + const { documentType } = args; throw Error(`Authentication failed: Invalid document type ${documentType} provided.`); } \ No newline at end of file diff --git a/live/src/ce/lib/update-document.ts b/live/src/ce/lib/update-document.ts index f784785dd..b998e154f 100644 --- a/live/src/ce/lib/update-document.ts +++ b/live/src/ce/lib/update-document.ts @@ -2,16 +2,14 @@ import { TDocumentTypes } from "@/core/types/common.js"; type TArgs = { - params: URLSearchParams; - pageId: string; - updatedDescription: Uint8Array; cookie: string | undefined; + documentType: TDocumentTypes | undefined; + pageId: string; + params: URLSearchParams; + updatedDescription: Uint8Array; } -export const updateDocument = (args: TArgs): Promise => { - const { params } = args; - const documentType = params.get("documentType")?.toString() as - | TDocumentTypes - | undefined; +export const updateDocument = async (args: TArgs): Promise => { + const { documentType } = args; throw Error(`Update failed: Invalid document type ${documentType} provided.`); } \ No newline at end of file diff --git a/live/src/core/lib/authentication.ts b/live/src/core/lib/authentication.ts index 6403b065e..581e5e8fa 100644 --- a/live/src/core/lib/authentication.ts +++ b/live/src/core/lib/authentication.ts @@ -18,8 +18,6 @@ type Props = { export const handleAuthentication = async (props: Props) => { const { connection, cookie, params, token } = props; // params - const workspaceSlug = params.get("workspaceSlug")?.toString(); - const projectId = params.get("projectId")?.toString(); const documentType = params.get("documentType")?.toString() as | TDocumentTypes | undefined; @@ -36,6 +34,9 @@ export const handleAuthentication = async (props: Props) => { } if (documentType === "project_page") { + // params + const workspaceSlug = params.get("workspaceSlug")?.toString(); + const projectId = params.get("projectId")?.toString(); if (!workspaceSlug || !projectId) { throw Error( "Authentication failed: Incomplete query params. Either workspaceSlug or projectId is missing." @@ -56,6 +57,7 @@ export const handleAuthentication = async (props: Props) => { await authenticateUser({ connection, cookie, + documentType, params }); } diff --git a/live/src/server.ts b/live/src/server.ts index 661004236..a64a6878b 100644 --- a/live/src/server.ts +++ b/live/src/server.ts @@ -108,10 +108,11 @@ const server = Server.configure({ await updatePageDescription(params, pageId, state, cookie); } else { await updateDocument({ - params, - pageId, - updatedDescription: state, cookie, + documentType, + pageId, + params, + updatedDescription: state, }) } } catch (error) {