From f23b03b649745e89ae012865ecbe011fc8bdfb6d Mon Sep 17 00:00:00 2001 From: John Coffey Date: Wed, 11 Nov 2026 11:39:19 -0700 Subject: [PATCH] Sign-in: the mail server's page shows the light or dark look in use here Login and Add account pass theme=light or theme=dark to /api/auth/oauth/start, which forwards only those two values on the authorize request (inbuxa-server #375, page support in server PR #376). A server that doesn't know the parameter ignores it. --- server/src/app.ts | 4 ++++ server/src/oauth.test.ts | 9 +++++++++ server/src/oauth.ts | 5 ++++- web/src/lib/signInTheme.ts | 8 ++++++++ web/src/views/AddAccountDialog.tsx | 3 ++- web/src/views/Login.tsx | 3 ++- 6 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 web/src/lib/signInTheme.ts diff --git a/server/src/app.ts b/server/src/app.ts index ad525ab..b88fbb0 100644 --- a/server/src/app.ts +++ b/server/src/app.ts @@ -540,6 +540,9 @@ export function createApp(basePath = config.basePath): Hono { * `callback` is where the server sends it back. See oauth.ts. */ const OAUTH_STATE_COOKIE = `${config.cookieName}_signin`; + /** The look the browser asked the server's sign-in page for, if it is one we pass on. */ + const signInTheme = (value: string | undefined): "light" | "dark" | undefined => + value === "light" || value === "dark" ? value : undefined; api.get("/auth/oauth/start", async (c) => { if (!oauthEnabled()) return c.json({ error: "not_found" }, 404); @@ -561,6 +564,7 @@ export function createApp(basePath = config.basePath): Hono { base: upstreamFor(username), remember: c.req.query("remember") === "1", adding: front !== null, + theme: signInTheme(c.req.query("theme")), }); setCookie(c, OAUTH_STATE_COOKIE, state, { httpOnly: true, sameSite: "Lax", secure: isSecureRequest(c), path: `${basePath}/api/auth`, maxAge: 600 }); return c.redirect(location, 302); diff --git a/server/src/oauth.test.ts b/server/src/oauth.test.ts index e15528b..f3c4f48 100644 --- a/server/src/oauth.test.ts +++ b/server/src/oauth.test.ts @@ -119,6 +119,15 @@ test("start sends the browser to the server's page with PKCE and a bound state", assert.equal(jar.get("ihm_session_signin"), to.searchParams.get("state"), "the state is bound to this browser"); }); +test("start passes on the light or dark look for the server's page, and nothing else", async () => { + const look = async (theme: string) => + new URL((await call(`/api/auth/oauth/start?username=demo@example.com&theme=${encodeURIComponent(theme)}`)).headers.get("location")!).searchParams.get("theme"); + assert.equal(await look("dark"), "dark"); + assert.equal(await look("light"), "light"); + assert.equal(await look("