From fe36631ff3321a2d27589bff6fc4e984936f37d3 Mon Sep 17 00:00:00 2001 From: LukeGus Date: Mon, 3 Nov 2025 19:10:44 -0600 Subject: [PATCH] fix: Android user agent edgecase and electron using web view incorrectly --- src/backend/utils/user-agent-parser.ts | 4 +++ src/ui/desktop/authentication/Auth.tsx | 43 ++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/backend/utils/user-agent-parser.ts b/src/backend/utils/user-agent-parser.ts index 7a56eb30..fb1a3563 100644 --- a/src/backend/utils/user-agent-parser.ts +++ b/src/backend/utils/user-agent-parser.ts @@ -22,6 +22,10 @@ export function detectPlatform(req: Request): DeviceType { return "mobile"; } + if (userAgent.includes("Android")) { + return "mobile"; + } + return "web"; } diff --git a/src/ui/desktop/authentication/Auth.tsx b/src/ui/desktop/authentication/Auth.tsx index 9dd827a9..0de49c8d 100644 --- a/src/ui/desktop/authentication/Auth.tsx +++ b/src/ui/desktop/authentication/Auth.tsx @@ -103,6 +103,7 @@ export function Auth({ const [totpCode, setTotpCode] = useState(""); const [totpTempToken, setTotpTempToken] = useState(""); const [totpLoading, setTotpLoading] = useState(false); + const [webviewAuthSuccess, setWebviewAuthSuccess] = useState(false); useEffect(() => { setInternalLoggedIn(loggedIn); @@ -241,6 +242,9 @@ export function Auth({ }, "*", ); + setWebviewAuthSuccess(true); + setLoading(false); + return; } catch (e) {} } @@ -414,6 +418,9 @@ export function Auth({ }, "*", ); + setWebviewAuthSuccess(true); + setTotpLoading(false); + return; } catch (e) {} } @@ -518,6 +525,9 @@ export function Auth({ }, "*", ); + setWebviewAuthSuccess(true); + setOidcLoading(false); + return; } catch (e) {} } } @@ -791,14 +801,41 @@ export function Auth({ style={{ maxHeight: "calc(100vh - 1rem)" }} {...props} > - {isInElectronWebView() && ( + {isInElectronWebView() && !webviewAuthSuccess && ( {t("auth.desktopApp")} {t("auth.loggingInToDesktopApp")} )} - {totpRequired && ( + {isInElectronWebView() && webviewAuthSuccess && ( +
+
+ + + +
+
+

+ {t("messages.loginSuccess")} +

+

+ {t("auth.redirectingToApp")} +

+
+
+ )} + {!webviewAuthSuccess && totpRequired && (

@@ -850,7 +887,7 @@ export function Auth({

)} - {!loggedIn && !authLoading && !totpRequired && ( + {!webviewAuthSuccess && !loggedIn && !authLoading && !totpRequired && ( <> {(() => { const hasLogin = passwordLoginAllowed && !firstUser;