diff --git a/live/src/authentication.ts b/live/src/authentication.ts index 808c2e04b9a..cf67e429a2a 100644 --- a/live/src/authentication.ts +++ b/live/src/authentication.ts @@ -21,15 +21,21 @@ export const handleAuthentication = async (props: Props) => { | TDocumentTypes | undefined; // fetch current user info - const response = await userService.currentUser(cookie); + let response; + try { + response = await userService.currentUser(cookie); + } catch (error) { + console.error("Failed to fetch current user:", error); + throw error; + } if (response.id !== token) { - throw Error("Token doesn't match"); + throw Error("Authentication failed: Token doesn't match the current user."); } if (documentType === "project_page") { if (!workspaceSlug || !projectId) { throw Error( - "Incomplete query params, workspaceSlug or projectId missing", + "Authentication failed: Incomplete query params. Either workspaceSlug or projectId is missing.", ); } // fetch current user's roles @@ -43,7 +49,7 @@ export const handleAuthentication = async (props: Props) => { connection.readOnly = true; } } else { - throw Error("Invalid document type provided"); + throw Error("Authentication failed: Invalid document type provided."); } return { diff --git a/live/src/page.ts b/live/src/page.ts index 95524308f0e..417c56e7e5b 100644 --- a/live/src/page.ts +++ b/live/src/page.ts @@ -26,6 +26,12 @@ export const updatePageDescription = async ( updatedDescription: Uint8Array, cookie: string | undefined, ) => { + if (!(updatedDescription instanceof Uint8Array)) { + throw new Error( + "Invalid updatedDescription: must be an instance of Uint8Array", + ); + } + const workspaceSlug = params.get("workspaceSlug")?.toString(); const projectId = params.get("projectId")?.toString(); if (!workspaceSlug || !projectId || !cookie) return; diff --git a/web/core/components/pages/editor/page-root.tsx b/web/core/components/pages/editor/page-root.tsx index 270de56650d..0e48cc8af98 100644 --- a/web/core/components/pages/editor/page-root.tsx +++ b/web/core/components/pages/editor/page-root.tsx @@ -25,7 +25,7 @@ export const PageRoot = observer((props: TPageRootProps) => { // states const [editorReady, setEditorReady] = useState(false); const [readOnlyEditorReady, setReadOnlyEditorReady] = useState(false); - const [sidePeekVisible, setSidePeekVisible] = useState(window.innerWidth >= 768 ? true : false); + const [sidePeekVisible, setSidePeekVisible] = useState(window.innerWidth >= 768); // refs const editorRef = useRef(null); const readOnlyEditorRef = useRef(null);