diff --git a/frontend/src/contexts/SettingsContext.tsx b/frontend/src/contexts/SettingsContext.tsx index c58588b..49153ca 100644 --- a/frontend/src/contexts/SettingsContext.tsx +++ b/frontend/src/contexts/SettingsContext.tsx @@ -9,6 +9,7 @@ import React, { import { useTranslation } from 'react-i18next'; import { ApiResponse, BearerKey } from '@/types'; import { useToast } from '@/contexts/ToastContext'; +import { useAuth } from '@/contexts/AuthContext'; import { apiGet, apiPut, apiPost, apiDelete } from '@/utils/fetchInterceptor'; // Define types for the settings data @@ -153,6 +154,7 @@ interface SettingsProviderProps { export const SettingsProvider: React.FC = ({ children }) => { const { t } = useTranslation(); const { showToast } = useToast(); + const { auth } = useAuth(); const [routingConfig, setRoutingConfig] = useState({ enableGlobalRoute: true, @@ -746,6 +748,15 @@ export const SettingsProvider: React.FC = ({ children }) fetchSettings(); }, [fetchSettings, refreshKey]); + // Watch for authentication status changes - refetch settings after login + useEffect(() => { + if (auth.isAuthenticated) { + console.log('[SettingsContext] User authenticated, triggering settings refresh'); + // When user logs in, trigger a refresh to load settings + triggerRefresh(); + } + }, [auth.isAuthenticated, triggerRefresh]); + useEffect(() => { if (routingConfig) { setTempRoutingConfig({