π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
update(photos):update-2fa-and-passkey-recovery-entry
Aswin Asok3b6c4eacd7aa
diff --git a/web/apps/photos/src/components/auth/RecoveryForm.tsx b/web/apps/photos/src/components/auth/RecoveryForm.tsxindex 5ce178aa33..be2f3a812b 100644--- a/web/apps/photos/src/components/auth/RecoveryForm.tsx+++ b/web/apps/photos/src/components/auth/RecoveryForm.tsx@@ -1,5 +1,6 @@import { styled } from "@mui/material";import type { RecoverAccountPresentationProps } from "ente-accounts/pages/recover";+import type { TwoFactorRecoverPresentationProps } from "ente-accounts/pages/two-factor/recover";import { pt } from "ente-base/i18n";import log from "ente-base/log";import { useFormik } from "formik";@@ -27,6 +28,20 @@ export function RecoverAccountForm();}+export function RecoverTwoFactorForm(+ props: TwoFactorRecoverPresentationProps,+): React.JSX.Element {+ return (+ <RecoveryForm+ {...props}+ title={t("recover_two_factor")}+ subtitle={pt(+ "Enter your recovery key to regain access to your account.",+ )}+ />+ );+}+interface RecoveryFormProps extends RecoverAccountPresentationProps {title: React.ReactNode;subtitle: React.ReactNode;diff --git a/web/apps/photos/src/pages/passkeys/recover.tsx b/web/apps/photos/src/pages/passkeys/recover.tsxindex 972142211c..65f5135646 100644--- a/web/apps/photos/src/pages/passkeys/recover.tsx+++ b/web/apps/photos/src/pages/passkeys/recover.tsx@@ -1,5 +1,32 @@-import Page_ from "ente-accounts/pages/two-factor/recover";+import { RecoverTwoFactorForm } from "@/components/auth/RecoveryForm";+import { PhotosAuthShell } from "@/components/PhotosAuthShell";+import { featureFlags } from "@/featureFlags";+import AccountsTwoFactorRecoverPage, {+ type TwoFactorRecoverPresentationProps,+} from "ente-accounts/pages/two-factor/recover";+import type React from "react";-const Page = () => <Page_ twoFactorType="passkey" />;+function RecoverTwoFactorPresentation(+ props: TwoFactorRecoverPresentationProps,+): React.JSX.Element {+ return (+ <PhotosAuthShell contentWidth={420}>+ <RecoverTwoFactorForm {...props} />+ </PhotosAuthShell>+ );+}-export default Page;+function PasskeyRecoverPage(): React.JSX.Element {+ if (!featureFlags.enableNewPhotosAuthFlow) {+ return <AccountsTwoFactorRecoverPage twoFactorType="passkey" />;+ }++ return (+ <AccountsTwoFactorRecoverPage+ twoFactorType="passkey"+ presentation={RecoverTwoFactorPresentation}+ />+ );+}++export default PasskeyRecoverPage;diff --git a/web/apps/photos/src/pages/two-factor/recover.tsx b/web/apps/photos/src/pages/two-factor/recover.tsxindex 201393276a..15a3cded54 100644--- a/web/apps/photos/src/pages/two-factor/recover.tsx+++ b/web/apps/photos/src/pages/two-factor/recover.tsx@@ -1,5 +1,32 @@-import Page_ from "ente-accounts/pages/two-factor/recover";+import { RecoverTwoFactorForm } from "@/components/auth/RecoveryForm";+import { PhotosAuthShell } from "@/components/PhotosAuthShell";+import { featureFlags } from "@/featureFlags";+import AccountsTwoFactorRecoverPage, {+ type TwoFactorRecoverPresentationProps,+} from "ente-accounts/pages/two-factor/recover";+import type React from "react";-const Page = () => <Page_ twoFactorType="totp" />;+function RecoverTwoFactorPresentation(+ props: TwoFactorRecoverPresentationProps,+): React.JSX.Element {+ return (+ <PhotosAuthShell contentWidth={420}>+ <RecoverTwoFactorForm {...props} />+ </PhotosAuthShell>+ );+}-export default Page;+function TwoFactorRecoverPage(): React.JSX.Element {+ if (!featureFlags.enableNewPhotosAuthFlow) {+ return <AccountsTwoFactorRecoverPage twoFactorType="totp" />;+ }++ return (+ <AccountsTwoFactorRecoverPage+ twoFactorType="totp"+ presentation={RecoverTwoFactorPresentation}+ />+ );+}++export default TwoFactorRecoverPage;diff --git a/web/packages/accounts/pages/two-factor/recover.tsx b/web/packages/accounts/pages/two-factor/recover.tsxindex e84ef3bec7..d9b83837a8 100644--- a/web/packages/accounts/pages/two-factor/recover.tsx+++ b/web/packages/accounts/pages/two-factor/recover.tsx@@ -23,14 +23,30 @@ import { isHTTP4xxError, isHTTPErrorWithStatus } from "ente-base/http";import log from "ente-base/log";import { t } from "i18next";import { useRouter } from "next/router";-import { useCallback, useEffect, useMemo, useState } from "react";+import {+ useCallback,+ useEffect,+ useMemo,+ useState,+ type ComponentType,+} from "react";import { Trans } from "react-i18next";+export interface TwoFactorRecoverPresentationProps {+ onSubmit: SingleInputFormProps["onSubmit"];+ onNoRecoveryKey: () => void;+ onBack: () => void;+}+export interface RecoverPageProps {twoFactorType: TwoFactorType;+ presentation?: ComponentType<TwoFactorRecoverPresentationProps>;}-const Page: React.FC<RecoverPageProps> = ({ twoFactorType }) => {+const Page: React.FC<RecoverPageProps> = ({+ twoFactorType,+ presentation: Presentation,+}) => {const { logout, showMiniDialog, onGenericError } = useBaseContext();const [sessionID, setSessionID] = useState<string | undefined>(undefined);@@ -59,6 +75,10 @@ const Page: React.FC<RecoverPageProps> = ({ twoFactorType }) => {[showMiniDialog],);+ function handleNoRecoveryKey() {+ showContactSupportDialog();+ }+useEffect(() => {void (async () => {const user = savedPartialLocalUser();@@ -119,6 +139,16 @@ const Page: React.FC<RecoverPageProps> = ({ twoFactorType }) => {return <LoadingIndicator />;}+ if (Presentation) {+ return (+ <Presentation+ onSubmit={handleSubmit}+ onNoRecoveryKey={handleNoRecoveryKey}+ onBack={router.back}+ />+ );+ }+return (<AccountsPageContents><AccountsPageTitle>{t("recover_two_factor")}</AccountsPageTitle>