Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

update(locker):2fa-choice-updated

Aswin Asok261f0009a42d
diff --git a/web/apps/locker/src/components/auth/SecondFactorChoiceDialog.tsx b/web/apps/locker/src/components/auth/SecondFactorChoiceDialog.tsx
new file mode 100644
index 0000000000..475264a817
--- /dev/null
+++ b/web/apps/locker/src/components/auth/SecondFactorChoiceDialog.tsx
@@ -0,0 +1,61 @@
+import { styled } from "@mui/material";
+import type { SecondFactorChoicePresentationProps } from "ente-accounts/components/SecondFactorChoice";
+import { t } from "i18next";
+import type React from "react";
+import {
+ AuthDialog,
+ AuthDialogHeader,
+ AuthDialogText,
+ AuthDialogTitle,
+} from "./AuthDialog";
+import { Button } from "./Button";
+import { authDialogContentLayout } from "./styles";
+
+export function SecondFactorChoiceDialog({
+ open,
+ onDialogClose,
+ onSelect,
+}: SecondFactorChoicePresentationProps): React.JSX.Element {
+ return (
+ <AuthDialog
+ open={open}
+ onClose={onDialogClose}
+ ariaLabelledby="second-factor-choice-title"
+ >
+ <ContentRoot>
+ <AuthDialogHeader>
+ <AuthDialogTitle id="second-factor-choice-title">
+ {t("two_factor")}
+ </AuthDialogTitle>
+ <AuthDialogText>
+ {t("auth_second_factor_choice_subtitle")}
+ </AuthDialogText>
+ </AuthDialogHeader>
+ <ButtonStack>
+ <Button
+ variant="primary"
+ fullWidth
+ onClick={() => onSelect("totp")}
+ >
+ {t("totp_login")}
+ </Button>
+ <Button
+ variant="secondary"
+ fullWidth
+ onClick={() => onSelect("passkey")}
+ >
+ {t("passkey_login")}
+ </Button>
+ </ButtonStack>
+ </ContentRoot>
+ </AuthDialog>
+ );
+}
+
+const ContentRoot = styled("div")(authDialogContentLayout);
+
+const ButtonStack = styled("div")({
+ display: "flex",
+ flexDirection: "column",
+ gap: "12px",
+});
diff --git a/web/apps/locker/src/pages/credentials.tsx b/web/apps/locker/src/pages/credentials.tsx
index 2c3a65ae5d..acbc9f264a 100644
--- a/web/apps/locker/src/pages/credentials.tsx
+++ b/web/apps/locker/src/pages/credentials.tsx
@@ -2,6 +2,7 @@ import {
CredentialsForm,
PasswordForm,
} from "@/components/auth/CredentialsForm";
+import { SecondFactorChoiceDialog } from "@/components/auth/SecondFactorChoiceDialog";
import { LockerAuthShell } from "@/components/LockerAuthShell";
import { featureFlags } from "@/featureFlags";
import AccountsCredentialsPage, {
@@ -28,6 +29,7 @@ function CredentialsPage(): React.JSX.Element {
<AccountsCredentialsPage
presentation={CredentialsPresentation}
passwordPresentation={PasswordForm}
+ secondFactorChoicePresentation={SecondFactorChoiceDialog}
/>
);
}
diff --git a/web/apps/locker/src/pages/verify.tsx b/web/apps/locker/src/pages/verify.tsx
index 692909e34a..2c0da1127b 100644
--- a/web/apps/locker/src/pages/verify.tsx
+++ b/web/apps/locker/src/pages/verify.tsx
@@ -1,3 +1,4 @@
+import { SecondFactorChoiceDialog } from "@/components/auth/SecondFactorChoiceDialog";
import { VerifyEmailForm } from "@/components/auth/VerifyEmailForm";
import { LockerAuthShell } from "@/components/LockerAuthShell";
import { featureFlags } from "@/featureFlags";
@@ -21,7 +22,12 @@ function VerifyPage(): React.JSX.Element {
return <AccountsVerifyPage />;
}
- return <AccountsVerifyPage presentation={VerifyEmailPresentation} />;
+ return (
+ <AccountsVerifyPage
+ presentation={VerifyEmailPresentation}
+ secondFactorChoicePresentation={SecondFactorChoiceDialog}
+ />
+ );
}
export default VerifyPage;