From 975dccebfcf51878b790a765d8e92ebcad895a24 Mon Sep 17 00:00:00 2001
From: Kamal Wickramanayake <kamal@inbox.lk>
Date: Sat, 4 Jul 2026 06:42:12 +0530
Subject: Microservice react-app - posts hidden for anonymous users

---
 microservices/04-react-app/src/App.jsx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'microservices/04-react-app/src/App.jsx')

diff --git a/microservices/04-react-app/src/App.jsx b/microservices/04-react-app/src/App.jsx
index aedd87e..956e60a 100644
--- a/microservices/04-react-app/src/App.jsx
+++ b/microservices/04-react-app/src/App.jsx
@@ -11,7 +11,7 @@ import AdminPage from "./pages/AdminPage";
 import { useAuth } from "./contexts/AuthContext";
 
 function App() {
-  const { isAdmin } = useAuth();
+  const { isLoggedIn, isAdmin } = useAuth();
 
   return (
     <div className="app">
@@ -20,7 +20,7 @@ function App() {
       <Routes>
         <Route index element={<HomePage />} />
         <Route path="about" element={<AboutPage />} />
-        <Route path="posts" element={<PostList />} />
+        <Route path="posts" element={isLoggedIn() ? <PostList /> : <Navigate to="/" />} />
 
         <Route path="admin" element={isAdmin() ? <AdminPage /> : <Navigate to="/" />} />
 
-- 
cgit v1.2.3

