This commit is contained in:
Manav Rathi
2024-06-07 10:33:01 +05:30
parent 5297156229
commit 3a97f16435
2 changed files with 6 additions and 7 deletions

View File

@@ -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<PageProps> = ({ 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);

View File

@@ -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<KeyAttributes | undefined>;