This commit is contained in:
Manav Rathi 2024-05-25 10:15:43 +05:30
parent 08073b927c
commit 19e08cf803
No known key found for this signature in database
4 changed files with 8 additions and 6 deletions

View file

@ -6,7 +6,7 @@ import { t } from "i18next";
import LinkButton from "@ente/shared/components/LinkButton";
interface Iprops {
twoFactorSecret: TwoFactorSecret;
twoFactorSecret?: TwoFactorSecret;
changeToQRMode: () => void;
}
export default function SetupManualMode({

View file

@ -7,7 +7,7 @@ import { Typography } from "@mui/material";
import { LoadingQRCode, QRCode } from "../styledComponents";
interface Iprops {
twoFactorSecret: TwoFactorSecret;
twoFactorSecret?: TwoFactorSecret;
changeToManualMode: () => void;
}

View file

@ -6,7 +6,7 @@ import { VerticallyCentered } from "@ente/shared/components/Container";
import { useState } from "react";
interface Iprops {
twoFactorSecret: TwoFactorSecret;
twoFactorSecret?: TwoFactorSecret;
}
export function TwoFactorSetup({ twoFactorSecret }: Iprops) {
const [setupMode, setSetupMode] = useState<SetupMode>(SetupMode.QR_CODE);

View file

@ -1,4 +1,5 @@
import log from "@/next/log";
import { ensure } from "@/utils/ensure";
import { enableTwoFactor, setupTwoFactor } from "@ente/accounts/api/user";
import VerifyTwoFactor, {
type VerifyTwoFactorCallback,
@ -23,8 +24,9 @@ export enum SetupMode {
}
export default function SetupTwoFactor({ appName }: PageProps) {
const [twoFactorSecret, setTwoFactorSecret] =
useState<TwoFactorSecret>(null);
const [twoFactorSecret, setTwoFactorSecret] = useState<
TwoFactorSecret | undefined
>();
const router = useRouter();
@ -48,7 +50,7 @@ export default function SetupTwoFactor({ appName }: PageProps) {
markSuccessful,
) => {
const recoveryEncryptedTwoFactorSecret = await encryptWithRecoveryKey(
twoFactorSecret.secretCode,
ensure(twoFactorSecret).secretCode,
);
await enableTwoFactor(otp, recoveryEncryptedTwoFactorSecret);
await markSuccessful();