diff --git a/src/components/Routes/ProtectedRoute.jsx b/src/components/Routes/ProtectedRoute.jsx new file mode 100644 index 0000000..0779a8b --- /dev/null +++ b/src/components/Routes/ProtectedRoute.jsx @@ -0,0 +1,12 @@ +import React from 'react'; +import { Redirect, Route } from 'react-router-dom'; +import { useUserContext } from '../Contexts/UserContext'; + +export const ProtectedRoute = ({ render, ...others }) => { + const { user, setError } = useUserContext(); + if (!user || !user.sub || user.sub.length === 0) { + setError('Please sign in to access'); + return ; + } + return ; +} \ No newline at end of file