diff --git a/app/scenes/DesktopRedirect.tsx b/app/scenes/DesktopRedirect.tsx
index 08093e10b7..9cdc2b6c5a 100644
--- a/app/scenes/DesktopRedirect.tsx
+++ b/app/scenes/DesktopRedirect.tsx
@@ -1,17 +1,12 @@
import { useEffect } from "react";
-import { useTranslation } from "react-i18next";
import styled from "styled-components";
-import { s } from "@shared/styles";
import Flex from "~/components/Flex";
-import Heading from "~/components/Heading";
-import PageTitle from "~/components/PageTitle";
-import Text from "~/components/Text";
import useQuery from "~/hooks/useQuery";
+import { SigningIn } from "./Login/components/SigningIn";
const DesktopRedirect = () => {
const params = useQuery();
const token = params.get("token");
- const { t } = useTranslation();
useEffect(() => {
if (token) {
@@ -28,30 +23,11 @@ const DesktopRedirect = () => {
return (
-
- {t("Signing in")}…
-
- {t(
- "You can safely close this window once the Outline desktop app has opened"
- )}
- .
-
+
);
};
-const Note = styled(Text)`
- color: ${s("textTertiary")};
- text-align: center;
- font-size: 14px;
- margin-top: 8px;
-
- em {
- font-style: normal;
- font-weight: 500;
- }
-`;
-
const Centered = styled(Flex)`
user-select: none;
width: 90vw;
diff --git a/app/scenes/Login/Login.tsx b/app/scenes/Login/Login.tsx
index 4b0426b54c..a2851c3ff4 100644
--- a/app/scenes/Login/Login.tsx
+++ b/app/scenes/Login/Login.tsx
@@ -40,6 +40,8 @@ import { BackButton } from "./components/BackButton";
import { Background } from "./components/Background";
import { Centered } from "./components/Centered";
import { Notices } from "./components/Notices";
+import { PasskeyAuthenticationProvider } from "./components/PasskeyAuthenticationProvider";
+import { SigningIn } from "./components/SigningIn";
import { SwitchHostButton } from "./components/SwitchHostButton";
import { navigateToSubdomain } from "./urls";
import lazyWithRetry from "~/utils/lazyWithRetry";
@@ -122,6 +124,14 @@ function Login({ children, onBack }: Props) {
// ceremony even when this browser already has a session.
const isPasskeyLogin = query.get("method") === "passkey";
+ // When the desktop app forces a passkey login it opens this page in the
+ // system browser, where the ceremony is triggered automatically. Show the
+ // "Signing in" screen rather than the login buttons.
+ const isDesktopPasskeyRedirect =
+ isPasskeyLogin &&
+ query.get("client") === Client.Desktop &&
+ !Desktop.isElectron();
+
if (auth.authenticated && !isPasskeyLogin) {
const postLoginPath = spendPostLoginPath();
if (postLoginPath) {
@@ -169,6 +179,22 @@ function Login({ children, onBack }: Props) {
return ;
}
+ // The passkey ceremony is triggered automatically here, so render the
+ // "Signing in" screen in place of the login buttons. The passkey provider is
+ // still mounted (hidden) to drive the ceremony and form submission, revealing
+ // a retry button if the ceremony fails.
+ if (isDesktopPasskeyRedirect) {
+ return (
+
+
+
+
+
+
+
+ );
+ }
+
const isCustomDomain = parseDomain(window.location.origin).custom;
// Unmapped custom domain
diff --git a/app/scenes/Login/components/PasskeyAuthenticationProvider.tsx b/app/scenes/Login/components/PasskeyAuthenticationProvider.tsx
index 58a5389364..5769b69ec2 100644
--- a/app/scenes/Login/components/PasskeyAuthenticationProvider.tsx
+++ b/app/scenes/Login/components/PasskeyAuthenticationProvider.tsx
@@ -64,6 +64,7 @@ export function PasskeyAuthenticationProvider(props: Props) {
null
);
const [isAuthenticating, setIsAuthenticating] = React.useState(false);
+ const [hasError, setHasError] = React.useState(false);
// True when this page was opened in the system browser from the desktop app
// to complete a passkey login (see the /auth/passkey route). In that case the
@@ -72,8 +73,14 @@ export function PasskeyAuthenticationProvider(props: Props) {
const isDesktopRedirect =
query.get("method") === "passkey" && query.get("client") === Client.Desktop;
+ // When returning to the system browser from the desktop app the ceremony is
+ // triggered automatically, so the button is hidden behind the "Signing in"
+ // screen. It is revealed again if the ceremony fails so the user can retry.
+ const autoStarting = isDesktopRedirect && !Desktop.isElectron();
+
const runAuthentication = React.useCallback(async (verifyClient: Client) => {
setIsAuthenticating(true);
+ setHasError(false);
try {
const resp = await client.post(
"/passkeys.generateAuthenticationOptions",
@@ -101,6 +108,7 @@ export function PasskeyAuthenticationProvider(props: Props) {
// Re-enable the button so the user can retry; on success the form submits
// and navigates away, so there's no need to reset there.
setIsAuthenticating(false);
+ setHasError(true);
}
}, []);
@@ -152,15 +160,17 @@ export function PasskeyAuthenticationProvider(props: Props) {
readOnly
/>
))}
- }
- fullwidth
- {...props}
- disabled={isAuthenticating}
- >
- {t("Continue with Passkey")}
-
+ {(!autoStarting || hasError) && (
+ }
+ fullwidth
+ {...props}
+ disabled={isAuthenticating}
+ >
+ {t("Continue with Passkey")}
+
+ )}
);
diff --git a/app/scenes/Login/components/SigningIn.tsx b/app/scenes/Login/components/SigningIn.tsx
new file mode 100644
index 0000000000..cf16eb3fe0
--- /dev/null
+++ b/app/scenes/Login/components/SigningIn.tsx
@@ -0,0 +1,42 @@
+import { useTranslation } from "react-i18next";
+import styled from "styled-components";
+import { s } from "@shared/styles";
+import Heading from "~/components/Heading";
+import PageTitle from "~/components/PageTitle";
+import Text from "~/components/Text";
+
+/**
+ * Renders the "Signing in…" screen shown while a login is being completed in
+ * the background, for example after handing a session back to the desktop app
+ * or while a passkey ceremony runs automatically.
+ *
+ * @returns the signing-in screen.
+ */
+export function SigningIn() {
+ const { t } = useTranslation();
+
+ return (
+ <>
+
+ {t("Signing in")}…
+
+ {t(
+ "You can safely close this window once the Outline desktop app has opened"
+ )}
+ .
+
+ >
+ );
+}
+
+const Note = styled(Text)`
+ color: ${s("textTertiary")};
+ text-align: center;
+ font-size: 14px;
+ margin-top: 8px;
+
+ em {
+ font-style: normal;
+ font-weight: 500;
+ }
+`;