Skip to content

A local-first personal finance app

:bug: Fix OIDC login callback on ipad (#8505)

Michael Clark05c8493d80bc
diff --git a/packages/desktop-client/src/browser-preload.js b/packages/desktop-client/src/browser-preload.js
index 9cac0a8ac4..0b44f70326 100644
--- a/packages/desktop-client/src/browser-preload.js
+++ b/packages/desktop-client/src/browser-preload.js
@@ -21,6 +21,19 @@ const ACTUAL_VERSION = Platform.isPlaywright
? '.preview'
: packageJson.version;
+// The OIDC callback (/openid-cb) is reached via a full-page navigation back
+// from the OpenID provider. Routing it through the SharedWorker coordinator is
+// unreliable: the returning tab can be left UNASSIGNED (no leader/backend), so
+// the token write hangs and login silently fails (worst on iOS/iPad, where the
+// pre-redirect tab never reports closing). It's a transient pre-login page with
+// no budget open, so it doesn't need multi-tab coordination — give it a direct
+// Worker so the token write resolves and login can complete. Once the user
+// opens a budget the app navigates and the next page load rejoins the
+// coordinator normally.
+const isOpenIdCallback = window.location.pathname
+ .replace(/\/+$/, '')
+ .endsWith('/openid-cb');
+
// *** Start the backend ***
//
// The multi-tab coordinator (leader/follower over SharedWorker), the direct
@@ -39,7 +52,10 @@ const worker = startBrowserBackend({
createSharedWorker: () =>
new SharedBrowserServerWorker({ name: 'actual-backend' }),
forceDirectWorker:
- Platform.isPlaywright || Platform.isIOS || Platform.isAndroid,
+ Platform.isPlaywright ||
+ Platform.isIOS ||
+ Platform.isAndroid ||
+ isOpenIdCallback,
});
let isUpdateReadyForDownload = false;
diff --git a/packages/desktop-client/src/components/manager/subscribe/OpenIdCallback.ts b/packages/desktop-client/src/components/manager/subscribe/OpenIdCallback.ts
index 6fdd7571b1..d8218ba948 100644
--- a/packages/desktop-client/src/components/manager/subscribe/OpenIdCallback.ts
+++ b/packages/desktop-client/src/components/manager/subscribe/OpenIdCallback.ts
@@ -7,9 +7,19 @@ import { loggedIn } from '#users/usersSlice';
export function OpenIdCallback() {
const dispatch = useDispatch();
+ // Intentionally NO dependency array: the effect re-runs on every render so
+ // the token write + login is retried until it succeeds and the manager
+ // navigates away from /openid-cb. On a fresh session the first attempt can
+ // fire before the token is stored or the backend connection is ready (its
+ // file-list fetch then 401s and `files` never loads); the re-runs are what
+ // recover it. Forcing this to run once regresses login on Electron and on a
+ // fresh web session, so don't add a dependency array here.
useEffect(() => {
const token = new URLSearchParams(window.location.search).get('token');
- void send('subscribe-set-token', { token: token as string }).then(() => {
+ if (!token) {
+ return;
+ }
+ void send('subscribe-set-token', { token }).then(() => {
void dispatch(loggedIn());
});
});
diff --git a/upcoming-release-notes/8505.md b/upcoming-release-notes/8505.md
new file mode 100644
index 0000000000..b9b3bcf450
--- /dev/null
+++ b/upcoming-release-notes/8505.md
@@ -0,0 +1,6 @@
+---
+category: Bugfixes
+authors: [MikesGlitch]
+---
+
+Fix OIDC login on iPad and harden the OIDC callback on all browsers