diff --git a/ChatbotApi/Constrollers/AuthController.cs b/ChatbotApi/Constrollers/AuthController.cs index 50cde52..1228226 100644 --- a/ChatbotApi/Constrollers/AuthController.cs +++ b/ChatbotApi/Constrollers/AuthController.cs @@ -67,6 +67,13 @@ public class AuthController : ControllerBase return Ok(new { message = "Sesión cerrada" }); } + [HttpGet("status")] + [Microsoft.AspNetCore.Authorization.AllowAnonymous] + public IActionResult GetStatus() + { + return Ok(new { isAuthenticated = User.Identity?.IsAuthenticated ?? false }); + } + #if DEBUG // [SEGURIDAD] Endpoint solo para desarrollo [HttpPost("setup-admin")] diff --git a/chatbot-admin/src/App.tsx b/chatbot-admin/src/App.tsx index d7a62fd..c77c879 100644 --- a/chatbot-admin/src/App.tsx +++ b/chatbot-admin/src/App.tsx @@ -16,10 +16,11 @@ function App() { const checkAuth = async () => { try { - // Intentamos acceder a un recurso protegido para verificar la cookie - await apiClient.get('/api/admin/contexto'); - setIsAuthenticated(true); + // Verificamos estado silenciosamente (sin generar 401 en consola) + const response = await apiClient.get('/api/auth/status'); + setIsAuthenticated(response.data.isAuthenticated); } catch (error) { + // Si falla la conexión (ej. 500), asumimos no autenticado setIsAuthenticated(false); } finally { setIsLoading(false);