From e46ed0db5c0b96a911a001fe596b4da925522b32 Mon Sep 17 00:00:00 2001
From: 2004vivek <119566938+2004vivek@users.noreply.github.com>
Date: Thu, 24 Oct 2024 18:11:42 +0530
Subject: [PATCH 1/4] Update App.jsx
Signed-off-by: 2004vivek <119566938+2004vivek@users.noreply.github.com>
---
client/src/App.jsx | 50 +++++-----------------------------------------
1 file changed, 5 insertions(+), 45 deletions(-)
diff --git a/client/src/App.jsx b/client/src/App.jsx
index 919d318..7d5d449 100644
--- a/client/src/App.jsx
+++ b/client/src/App.jsx
@@ -84,7 +84,7 @@ function App() {
};
const [progress, setProgress] = useState(0);
-
+ const [islogged,setloggedin]=useState(false)
useEffect(() => {
const savedMode = localStorage.getItem("mode");
if (savedMode) {
@@ -158,39 +158,9 @@ function App() {
/>
}
/>
-
- }
- />
-
- }
- />
-
- }
- />
+ } />
+ } />
+ } />
}
/>
-
- }
- />
+ } />
Date: Thu, 24 Oct 2024 18:13:12 +0530
Subject: [PATCH 2/4] Create ProtectedRoute.jsx
Signed-off-by: 2004vivek <119566938+2004vivek@users.noreply.github.com>
---
client/src/component/ProtectedRoute.jsx | 11 +++++++++++
1 file changed, 11 insertions(+)
create mode 100644 client/src/component/ProtectedRoute.jsx
diff --git a/client/src/component/ProtectedRoute.jsx b/client/src/component/ProtectedRoute.jsx
new file mode 100644
index 0000000..8dc70b1
--- /dev/null
+++ b/client/src/component/ProtectedRoute.jsx
@@ -0,0 +1,11 @@
+
+import { Navigate } from 'react-router-dom'
+export default function ProtectedRoute({loggedin,children}) {
+ console.log(loggedin);
+ if(loggedin){
+ return children
+ }
+ else{
+ return
+ }
+}
From 5a8757bf4d20b307d8884b9b29a54c7fb65e45df Mon Sep 17 00:00:00 2001
From: 2004vivek <119566938+2004vivek@users.noreply.github.com>
Date: Thu, 24 Oct 2024 18:14:18 +0530
Subject: [PATCH 3/4] Update App.jsx
Signed-off-by: 2004vivek <119566938+2004vivek@users.noreply.github.com>
---
client/src/App.jsx | 1 +
1 file changed, 1 insertion(+)
diff --git a/client/src/App.jsx b/client/src/App.jsx
index 7d5d449..bb2b73e 100644
--- a/client/src/App.jsx
+++ b/client/src/App.jsx
@@ -36,6 +36,7 @@ import VerifyEmail from "./component/Verify";
import NotFound from "./component/NotFound";
import MiniChatbot from "./component/MiniChatbot";
import ProgressBar from "./component/ProgressBar/ProgressBar";
+import ProtectedRoute from '../../client/src/component/ProtectedRoute'
// Main Layout Component
From 1bd702c7ed2a2250375617f0d4cd5de13307e2cd Mon Sep 17 00:00:00 2001
From: 2004vivek <119566938+2004vivek@users.noreply.github.com>
Date: Thu, 24 Oct 2024 18:19:03 +0530
Subject: [PATCH 4/4] Update Login.jsx
Signed-off-by: 2004vivek <119566938+2004vivek@users.noreply.github.com>
---
client/src/component/Login.jsx | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/client/src/component/Login.jsx b/client/src/component/Login.jsx
index bef3359..def59e8 100644
--- a/client/src/component/Login.jsx
+++ b/client/src/component/Login.jsx
@@ -13,7 +13,7 @@ import toast from "react-hot-toast";
const VITE_SERVER_PORT = import.meta.env.VITE_SERVER_PORT || 'https://bitbox-uxbo.onrender.com';
-const Login = ({ mode, showAlert }) => {
+const Login = ({ mode, showAlert,isloggedin,setloggedin }) => {
const [credentials, setCredentials] = useState({ email: "", password: "" });
const [loading, setLoading] = useState(false);
@@ -36,6 +36,7 @@ const Login = ({ mode, showAlert }) => {
localStorage.setItem("token", json.authtoken);
showAlert("Logged in Successfully", "success");
toast.success("Login Successfully!");
+ setloggedin(!isloggedin)
navigate("/");
} else {
showAlert("Invalid Credentials", "danger");