Use token var instead of signedIn or user

This commit is contained in:
jwu-fisker
2021-01-05 19:11:38 -08:00
parent 1b39027209
commit c129d6ac1d
3 changed files with 9 additions and 14 deletions

View File

@@ -3,8 +3,8 @@ 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) {
const { token, setError } = useUserContext();
if (!token) {
setError('Please sign in to access');
return <Redirect to="/" />;
}