diff --git a/web/packages/accounts/pages/credentials.tsx b/web/packages/accounts/pages/credentials.tsx index 33741d3dee..b7bae310c0 100644 --- a/web/packages/accounts/pages/credentials.tsx +++ b/web/packages/accounts/pages/credentials.tsx @@ -18,7 +18,7 @@ import { } from "@ente/shared/crypto/helpers"; import type { B64EncryptionResult } from "@ente/shared/crypto/types"; import { CustomError } from "@ente/shared/error"; -import { accountsAppURL, apiOrigin } from "@ente/shared/network/api"; +import { apiOrigin } from "@ente/shared/network/api"; import InMemoryStore, { MS_KEYS } from "@ente/shared/storage/InMemoryStore"; import { LS_KEYS, @@ -44,6 +44,7 @@ import { useRouter } from "next/router"; import { useEffect, useState } from "react"; import { getSRPAttributes } from "../api/srp"; import { PAGES } from "../constants/pages"; +import { redirectUserToPasskeyVerificationFlow } from "../services/passkey"; import { appHomeRoute } from "../services/redirect"; import { configureSRP, @@ -166,10 +167,8 @@ const Page: React.FC = ({ appContext }) => { isTwoFactorPasskeysEnabled: true, }); InMemoryStore.set(MS_KEYS.REDIRECT_URL, PAGES.ROOT); - window.location.href = `${accountsAppURL()}/passkeys/verify?passkeySessionID=${passkeySessionID}&redirect=${ - window.location.origin - }/passkeys/finish`; - return undefined; + redirectUserToPasskeyVerificationFlow(passkeySessionID); + throw Error(CustomError.TWO_FACTOR_ENABLED); } else if (twoFactorSessionID) { const sessionKeyAttributes = await cryptoWorker.generateKeyAndEncryptToB64(kek); diff --git a/web/packages/shared/components/VerifyMasterPasswordForm.tsx b/web/packages/shared/components/VerifyMasterPasswordForm.tsx index 58ee4fbdf4..b1ec1bbf44 100644 --- a/web/packages/shared/components/VerifyMasterPasswordForm.tsx +++ b/web/packages/shared/components/VerifyMasterPasswordForm.tsx @@ -23,8 +23,8 @@ export interface VerifyMasterPasswordFormProps { /** * A callback invoked when the form wants to get {@link KeyAttributes}. * - * Returning `undefined` from this callback is not an error, in it signals - * to the form that some other form of second factor is enabled and the user + * This function can throw an `CustomError.TWO_FACTOR_ENABLED` to signal to + * the form that some other form of second factor is enabled and the user * has been redirected to a two factor verification page. */ getKeyAttributes?: (kek: string) => Promise;