From 3d15ec753f93babcc1fa0cf3958f1f164e98fea4 Mon Sep 17 00:00:00 2001 From: soryu Date: Sun, 11 Jan 2026 03:43:10 +0000 Subject: Disable buttons if logged out Also add prod.env for FE config --- makima/frontend/src/routes/files.tsx | 32 ++++++++++++++++++++++++++++++++ makima/frontend/src/routes/mesh.tsx | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) (limited to 'makima/frontend/src/routes') diff --git a/makima/frontend/src/routes/files.tsx b/makima/frontend/src/routes/files.tsx index 0645b85..3ba2d52 100644 --- a/makima/frontend/src/routes/files.tsx +++ b/makima/frontend/src/routes/files.tsx @@ -14,8 +14,40 @@ import { } from "../hooks/useFileSubscription"; import type { FileDetail as FileDetailType, BodyElement, Task } from "../lib/api"; import { createTask } from "../lib/api"; +import { useAuth } from "../contexts/AuthContext"; export default function FilesPage() { + const { isAuthenticated, isAuthConfigured, isLoading: authLoading } = useAuth(); + const navigate = useNavigate(); + + // Redirect to login if not authenticated (when auth is configured) + useEffect(() => { + if (!authLoading && isAuthConfigured && !isAuthenticated) { + navigate("/login"); + } + }, [authLoading, isAuthConfigured, isAuthenticated, navigate]); + + // Show loading while checking auth + if (authLoading) { + return ( +
+ +
+

Loading...

+
+
+ ); + } + + // Don't render if not authenticated (will redirect) + if (isAuthConfigured && !isAuthenticated) { + return null; + } + + return ; +} + +function FilesPageContent() { const { id } = useParams<{ id: string }>(); const navigate = useNavigate(); const { files, loading, error, conflict, clearConflict, fetchFile, editFile, removeFile, saveFile } = useFiles(); diff --git a/makima/frontend/src/routes/mesh.tsx b/makima/frontend/src/routes/mesh.tsx index 852ce58..7ecf96d 100644 --- a/makima/frontend/src/routes/mesh.tsx +++ b/makima/frontend/src/routes/mesh.tsx @@ -9,6 +9,7 @@ import { useTasks } from "../hooks/useTasks"; import { useTaskSubscription, type TaskUpdateEvent, type TaskOutputEvent } from "../hooks/useTaskSubscription"; import type { TaskWithSubtasks, MeshChatContext } from "../lib/api"; import { startTask as startTaskApi, stopTask as stopTaskApi, getTaskOutput } from "../lib/api"; +import { useAuth } from "../contexts/AuthContext"; // View modes for the task detail page type ViewMode = "split" | "task" | "output"; @@ -76,7 +77,15 @@ function clearPersistedOutput(taskId: string): void { export default function MeshPage() { const { id } = useParams<{ id: string }>(); const navigate = useNavigate(); + const { isAuthenticated, isAuthConfigured, isLoading: authLoading } = useAuth(); const { tasks, loading, error, conflict, clearConflict, fetchTask, fetchTasks, editTask, removeTask, saveTask } = useTasks(); + + // Redirect to login if not authenticated + useEffect(() => { + if (!authLoading && isAuthConfigured && !isAuthenticated) { + navigate("/login"); + } + }, [authLoading, isAuthConfigured, isAuthenticated, navigate]); const [taskDetail, setTaskDetail] = useState(null); const [detailLoading, setDetailLoading] = useState(false); const [creating, setCreating] = useState(false); @@ -488,6 +497,30 @@ export default function MeshPage() { } }; + // Show loading state while checking auth + if (authLoading) { + return ( +
+ +
+
Loading...
+
+
+ ); + } + + // Don't render content if not authenticated (redirect will happen via useEffect) + if (isAuthConfigured && !isAuthenticated) { + return ( +
+ +
+
Redirecting to login...
+
+
+ ); + } + return (
-- cgit v1.2.3