diff --git a/apps/web/src/views/recovery.tsx b/apps/web/src/views/recovery.tsx index aaff67bec..e2be98631 100644 --- a/apps/web/src/views/recovery.tsx +++ b/apps/web/src/views/recovery.tsx @@ -30,7 +30,6 @@ import { ErrorText } from "../components/error-text"; import { EVENTS, User } from "@notesnook/core"; import { RecoveryKeyDialog } from "../dialogs/recovery-key-dialog"; import { strings } from "@notesnook/intl"; -import { useKeyStore } from "../interfaces/key-store"; type RecoveryMethodType = "key" | "reset"; type RecoveryMethodsFormData = Record; @@ -105,8 +104,8 @@ function useAuthenticateUser({ code, userId }: { - code: string; - userId: string; + code?: string; + userId?: string; }) { const [isAuthenticating, setIsAuthenticating] = useState(true); const [user, setUser] = useState(); @@ -114,6 +113,10 @@ function useAuthenticateUser({ async function authenticateUser() { setIsAuthenticating(true); try { + if (!code || !userId) { + throw new Error("Missing code or userId in query params."); + } + const accessToken = await db.tokenManager.getAccessToken(); if (!accessToken) { await db.tokenManager.getAccessTokenFromAuthorizationCode( @@ -181,7 +184,7 @@ function Recovery(props: RecoveryProps) { }} variant={"body"} > - {strings.authenticatedAs(user?.email)} + {user?.email ? strings.authenticatedAs(user.email) : ""} - +