Skip to content

armgit / ente

Public Imported from GitHub
0

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

Don't reload the app, use the router

Manav Rathi8ecb88cbb472
diff --git a/desktop/src/main.ts b/desktop/src/main.ts
index 0bb56b4494..df16703fd6 100644
--- a/desktop/src/main.ts
+++ b/desktop/src/main.ts
@@ -150,6 +150,8 @@ const registerForEnteLinks = () => app.setAsDefaultProtocolClient("ente");
/** Sibling of {@link registerForEnteLinks}. */
const handleEnteLinks = (mainWindow: BrowserWindow, url: string) => {
+ // [Note: Using deeplinks to navigate in desktop app]
+ //
// Both
//
// - our deeplink protocol, and
diff --git a/web/apps/photos/src/pages/_app.tsx b/web/apps/photos/src/pages/_app.tsx
index 3d21ee56cf..6b4693564a 100644
--- a/web/apps/photos/src/pages/_app.tsx
+++ b/web/apps/photos/src/pages/_app.tsx
@@ -15,6 +15,7 @@ import {
} from "@/next/types/app";
import { AppUpdate } from "@/next/types/ipc";
import { ensure } from "@/utils/ensure";
+import { passkeyAuthenticationFinishRedirect } from "@ente/accounts/services/passkey";
import { Overlay } from "@ente/shared/components/Container";
import DialogBox from "@ente/shared/components/DialogBox";
import {
@@ -172,10 +173,8 @@ export default function App({ Component, pageProps }: AppProps) {
// the user is logged in.
const handleOpenURL = (url: string) => {
- // `url` begins with "ente://", which is also the scheme our desktop
- // app uses to serve the bundled web app, so it can be directly
- // opened.
- window.location.href = url;
+ if (url == passkeyAuthenticationFinishRedirect()) router.push(url);
+ else log.info(`Ignoring unhandled open request for URL ${url}`);
};
const showUpdateDialog = (update: AppUpdate) => {
diff --git a/web/packages/accounts/services/passkey.ts b/web/packages/accounts/services/passkey.ts
index b3315125ea..a85f8c1c7c 100644
--- a/web/packages/accounts/services/passkey.ts
+++ b/web/packages/accounts/services/passkey.ts
@@ -12,6 +12,17 @@ import HTTPService from "@ente/shared/network/HTTPService";
import { accountsAppURL, apiOrigin } from "@ente/shared/network/api";
import { getToken } from "@ente/shared/storage/localStorage/helpers";
+/**
+ * Return a URL that can be passed to the accounts app to serve as the redirect
+ * back to us on successful passkey authentication.
+ *
+ * The returned URL begins with `window.location.origin` and will work both when
+ * we're running in a web browser (of course), but also in the desktop app
+ * (See: [Note: Using deeplinks to navigate in desktop app]).
+ */
+export const passkeyAuthenticationFinishRedirect = () =>
+ `${window.location.origin}/passkeys/finish`;
+
/**
* Redirect user to Ente accounts app to authenticate using their second factor,
* a passkey they've configured.
@@ -29,7 +40,7 @@ export const redirectUserToPasskeyVerificationFlow = (
passkeySessionID: string,
) => {
const clientPackage = clientPackageName[appName];
- const redirect = `${window.location.origin}/passkeys/finish`;
+ const redirect = passkeyAuthenticationFinishRedirect();
const params = new URLSearchParams({
clientPackage,
passkeySessionID,