diff --git a/src/services/auth/oauth.test.ts b/src/services/auth/oauth.test.ts index 9bba7db..2efd74e 100644 --- a/src/services/auth/oauth.test.ts +++ b/src/services/auth/oauth.test.ts @@ -167,6 +167,7 @@ describe('startAuthFlow', () => { code_challenge_method: 'S256', state: stored.state, prompt: 'login', + theme: 'light', scope: 'openid profile offline_access', }); expect(stored.state).toMatch(/^[0-9a-f]{32}$/); @@ -177,6 +178,15 @@ describe('startAuthFlow', () => { }); }); + it("asks the sign-in page for the console's dark look when it shows one", async () => { + document.documentElement.classList.add('dark'); + try { + expect((await signIn(null)).searchParams.get('theme')).toBe('dark'); + } finally { + document.documentElement.classList.remove('dark'); + } + }); + it('prefills the account when given one', async () => { expect((await signIn('ann@example.org')).searchParams.get('login_hint')).toBe('ann@example.org'); }); diff --git a/src/services/auth/oauth.ts b/src/services/auth/oauth.ts index 7bbaa20..b94bbc8 100644 --- a/src/services/auth/oauth.ts +++ b/src/services/auth/oauth.ts @@ -192,6 +192,8 @@ export async function startAuthFlow(username: string | null, returnUrl?: string state, // Always ask for the password: a console session should never start silently. prompt: 'login', + // The sign-in page shows the console's own light or dark look (inbuxa-server #375). + theme: document.documentElement.classList.contains('dark') ? 'dark' : 'light', }); if (username) query.set('login_hint', username); const scope = scopesFor(endpoints.scopes_supported);