aboutsummaryrefslogtreecommitdiffstats
path: root/panel/src/components
diff options
context:
space:
mode:
authorLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-07-31 12:16:49 +0530
committerLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-07-31 12:16:49 +0530
commit7dfbe0f363a434cfda5f9be996d194f03c36879c (patch)
treeae687ee38c31106807934fca524811eb45da0ec9 /panel/src/components
downloadadmin-panel-7dfbe0f363a434cfda5f9be996d194f03c36879c.tar.gz
admin-panel-7dfbe0f363a434cfda5f9be996d194f03c36879c.tar.bz2
admin-panel-7dfbe0f363a434cfda5f9be996d194f03c36879c.zip
new project
Diffstat (limited to 'panel/src/components')
-rw-r--r--panel/src/components/PrivateRoute.jsx10
1 files changed, 10 insertions, 0 deletions
diff --git a/panel/src/components/PrivateRoute.jsx b/panel/src/components/PrivateRoute.jsx
new file mode 100644
index 0000000..04e00f7
--- /dev/null
+++ b/panel/src/components/PrivateRoute.jsx
@@ -0,0 +1,10 @@
+import React from 'react';
+import { Navigate, Outlet } from 'react-router-dom';
+import { useAuth } from '../contexts/AuthContext';
+
+const PrivateRoute = () => {
+ const { currentUser } = useAuth();
+ return currentUser ? <Outlet /> : <Navigate to="/login" />;
+};
+
+export default PrivateRoute;