From ae3e3a64f0fc771336c584ab9fabf7dfe4abe122 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Sat, 13 Dec 2025 16:09:48 +0000 Subject: [PATCH] fix: Make OIDC toggle auto-save when disabling - Disabling OIDC now saves immediately (safe operation) - Enabling requires Save button press (prevents lockout without config) - Shows helpful hint when enabling: configure first, then save --- .../src/components/Settings/OIDCPanel.tsx | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/frontend-modern/src/components/Settings/OIDCPanel.tsx b/frontend-modern/src/components/Settings/OIDCPanel.tsx index a6150d9..da6024b 100644 --- a/frontend-modern/src/components/Settings/OIDCPanel.tsx +++ b/frontend-modern/src/components/Settings/OIDCPanel.tsx @@ -221,8 +221,34 @@ export const OIDCPanel: Component = (props) => { /> { - setForm('enabled', event.currentTarget.checked); + onChange={async (event) => { + const newValue = event.currentTarget.checked; + setForm('enabled', newValue); + + // Auto-save when DISABLING (safe operation) + // When ENABLING, require full form save to ensure issuerUrl and clientId are set + if (!newValue && config()?.enabled) { + try { + const { apiFetch } = await import('@/utils/apiClient'); + const response = await apiFetch('/api/security/oidc', { + method: 'PUT', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ enabled: false }), + }); + if (!response.ok) throw new Error('Failed to disable OIDC'); + const updated = (await response.json()) as OIDCConfigResponse; + setConfig(updated); + notificationStore.success('OIDC disabled'); + props.onConfigUpdated?.(updated); + } catch (error) { + setForm('enabled', true); // Revert + logger.error('[OIDCPanel] Failed to disable OIDC:', error); + notificationStore.error('Failed to disable OIDC'); + } + } else if (newValue && !config()?.enabled) { + // Show hint that save is required + notificationStore.info('Configure issuer URL and client ID, then click Save', 3000); + } }} disabled={isEnvLocked() || loading() || saving()} containerClass="items-center gap-2"