From d25682397db573d5b37d9d81353c10a4cb9082e8 Mon Sep 17 00:00:00 2001 From: KansaiGaijin <83641841+KansaiGaijin@users.noreply.github.com> Date: Thu, 30 Jul 2026 13:54:14 +1200 Subject: [PATCH] fix login redirect loop: skip settings check when unauthenticated, only redirect 401 when token present --- frontend/src/App.tsx | 12 ++++++++---- frontend/src/contexts/AuthContext.tsx | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 72e84f0..d5ea7b5 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect } from 'react'; +import { useState, useEffect, useCallback } from 'react'; import { Routes, Route, Navigate } from 'react-router-dom'; import { AuthProvider, useAuth } from './contexts/AuthContext'; import Login from './pages/Login'; @@ -20,18 +20,22 @@ function AppInner() { const [loading, setLoading] = useState(true); const [isConfigured, setIsConfigured] = useState(false); - const checkSettings = () => { + const checkSettings = useCallback(() => { api.getSettings() .then(data => { setIsConfigured(!!(data && data.onboarding_completed)); }) .catch(() => setIsConfigured(false)) .finally(() => setLoading(false)); - }; + }, []); useEffect(() => { + if (!user) { + setLoading(false); + return; + } checkSettings(); - }, []); + }, [user, checkSettings]); if (authLoading || loading) { return