diff --git a/src/App.tsx b/src/App.tsx index c09ef99..5111677 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -8,10 +8,10 @@ import ForgotPassword from "./Pages/ForgotPassword"; import VerifyEnterOTP from "./Pages/VerifyEnterOTP"; import SetNewPassword from "./Pages/SetNewPassword"; -function App() { - const context = useContext(GlobalStateContext); - if (!context) throw new Error("App must be used within a GlobalStateProvider"); - +function App() { + const context = useContext(GlobalStateContext); + if (!context) throw new Error("App must be used within a GlobalStateProvider"); + const { isAuthenticate, setIsAuthenticate } = context; useEffect(() => { @@ -21,19 +21,19 @@ function App() { console.log("Auth Status:", isAuthenticate); - return ( - - + return ( + + {/* Redirect logged-in users away from login */} - : } /> + : } /> } /> } /> } /> {/* Protected Routes */} - {RouteLink.map(({ path, Component }, index) => ( @@ -42,15 +42,24 @@ function App() { ) : ( - - )} - /> + + {/* Allow only forgot password flows */} + } /> + } /> {/* ✅ Add this line */} + } /> + } /> + + {/* Default to login */} + } /> + + )} + /> {/* Catch-all route to prevent unauthorized access */} - } /> - - - ); -} + } /> + + + ); +} export default App;