aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/PrivateRoute.jsx
diff options
context:
space:
mode:
authorLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-07-25 23:29:15 +0530
committerLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-07-25 23:29:15 +0530
commit99e8a0e5360f397c5bbac5ae1a952cba98cf54fb (patch)
tree9d68d3c9f1e46dd137d75b99f43764af47de56fd /src/utils/PrivateRoute.jsx
parent680f38b1c48c4cc5c4b34b285f68fe48217d0ab9 (diff)
downloadadmin-panel-99e8a0e5360f397c5bbac5ae1a952cba98cf54fb.tar.gz
admin-panel-99e8a0e5360f397c5bbac5ae1a952cba98cf54fb.tar.bz2
admin-panel-99e8a0e5360f397c5bbac5ae1a952cba98cf54fb.zip
added login and registation methods
Diffstat (limited to 'src/utils/PrivateRoute.jsx')
-rw-r--r--src/utils/PrivateRoute.jsx9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/utils/PrivateRoute.jsx b/src/utils/PrivateRoute.jsx
new file mode 100644
index 0000000..b57bcf5
--- /dev/null
+++ b/src/utils/PrivateRoute.jsx
@@ -0,0 +1,9 @@
+import React from 'react';
+import { Navigate } from 'react-router-dom';
+
+const PrivateRoute = ({ children }) => {
+ const token = localStorage.getItem('token');
+ return token ? children : <Navigate to="/" />;
+};
+
+export default PrivateRoute;