Skip to content

armgit / ente

Public Imported from GitHub
0

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

Reuse

Manav Rathid513019e1b6d
diff --git a/web/packages/accounts/pages/verify.tsx b/web/packages/accounts/pages/verify.tsx
index 22cb61af60..53ea421eef 100644
--- a/web/packages/accounts/pages/verify.tsx
+++ b/web/packages/accounts/pages/verify.tsx
@@ -27,16 +27,23 @@ import { useEffect, useState } from "react";
import { Trans } from "react-i18next";
import { putAttributes, sendOtt, verifyOtt } from "../api/user";
import { PAGES } from "../constants/pages";
-import { redirectUserToPasskeyVerificationFlow } from "../services/passkey";
+import {
+ openPasskeyVerificationURL,
+ passkeyVerificationRedirectURL,
+} from "../services/passkey";
import { configureSRP } from "../services/srp";
import type { PageProps } from "../types/page";
import type { SRPSetupAttributes } from "../types/srp";
+import { VerifyingPasskey } from "@ente/shared/components/LoginComponents";
const Page: React.FC<PageProps> = ({ appContext }) => {
const { appName, logout } = appContext;
const [email, setEmail] = useState("");
const [resend, setResend] = useState(0);
+ const [passkeyVerificationURL, setPasskeyVerificationURL] = useState<
+ string | undefined
+ >();
const router = useRouter();
@@ -87,10 +94,12 @@ const Page: React.FC<PageProps> = ({ appContext }) => {
// TODO: This is not the first login though if they already have
// 2FA. Does this flag mean first login on this device?
setIsFirstLogin(true);
- redirectUserToPasskeyVerificationFlow(
+ const url = passkeyVerificationRedirectURL(
appName,
passkeySessionID,
);
+ setPasskeyVerificationURL(url);
+ openPasskeyVerificationURL(url);
} else if (twoFactorSessionID) {
setData(LS_KEYS.USER, {
email,
@@ -155,6 +164,8 @@ const Page: React.FC<PageProps> = ({ appContext }) => {
setTimeout(() => setResend(0), 3000);
};
+ const redirectToRecoverPage = () => router.push(PAGES.RECOVER);
+
if (!email) {
return (
<VerticallyCentered>
@@ -163,6 +174,24 @@ const Page: React.FC<PageProps> = ({ appContext }) => {
);
}
+ if (passkeyVerificationURL) {
+ // We reach this case only when running in the desktop app, because in
+ // the web app we already would've redirected to passkeyVerificationURL.
+ //
+ // See: [Note: Passkey verification in the desktop app]
+
+ return (
+ <VerifyingPasskey
+ email={email}
+ onRetry={() =>
+ openPasskeyVerificationURL(passkeyVerificationURL)
+ }
+ onRecover={redirectToRecoverPage}
+ onLogout={logout}
+ />
+ );
+ }
+
return (
<VerticallyCentered>
<FormPaper>