diff --git a/Client/src/App.jsx b/Client/src/App.jsx index fa2602cac..18573bba8 100644 --- a/Client/src/App.jsx +++ b/Client/src/App.jsx @@ -27,14 +27,25 @@ function App() { path="/monitors" element={} /> - - } /> - } /> - } /> - } /> + } + /> + } + /> + } + /> + } + /> + } /> + } /> - } /> - } /> } /> {/* } /> */} } /> diff --git a/Client/src/Components/NavBar/index.jsx b/Client/src/Components/NavBar/index.jsx index 9dedbcb61..a568b229d 100644 --- a/Client/src/Components/NavBar/index.jsx +++ b/Client/src/Components/NavBar/index.jsx @@ -55,7 +55,7 @@ function NavBar() { // Clear auth state dispatch(clearAuthState()); dispatch(clearMonitorState()); - navigate("/"); + navigate("/login"); }; /** diff --git a/Client/src/Components/ProtectedRoute/index.jsx b/Client/src/Components/ProtectedRoute/index.jsx index 38a777be9..5665e9317 100644 --- a/Client/src/Components/ProtectedRoute/index.jsx +++ b/Client/src/Components/ProtectedRoute/index.jsx @@ -1,4 +1,4 @@ -import { Route, Navigate } from "react-router-dom"; +import { Navigate } from "react-router-dom"; import { useSelector } from "react-redux"; import PropTypes from "prop-types"; @@ -15,9 +15,12 @@ import PropTypes from "prop-types"; const ProtectedRoute = ({ Component, ...rest }) => { const authState = useSelector((state) => state.auth); - console.log(authState); - return true ? : ; + return authState.authToken ? ( + + ) : ( + + ); }; ProtectedRoute.propTypes = { diff --git a/Client/src/Pages/Login/index.jsx b/Client/src/Pages/Login/index.jsx index c67f67ec1..18bca8a05 100644 --- a/Client/src/Pages/Login/index.jsx +++ b/Client/src/Pages/Login/index.jsx @@ -52,9 +52,7 @@ const Login = () => { await loginValidation.validateAsync(form, { abortEarly: false }); const action = await dispatch(login(form)); if (action.meta.requestStatus === "fulfilled") { - const token = action.payload.data; - localStorage.setItem("token", token); - navigate("/"); + navigate("/monitors"); } if (action.meta.requestStatus === "rejected") { const error = new Error("Request rejected");