From 4e9d9f7d15739d18dd2920a4fac8f37c260ecd85 Mon Sep 17 00:00:00 2001 From: canove Date: Mon, 26 Oct 2020 14:45:15 -0300 Subject: [PATCH] fix: not redirecting away from login page when logged in --- frontend/src/context/Auth/useAuth.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/frontend/src/context/Auth/useAuth.js b/frontend/src/context/Auth/useAuth.js index 3c568ee..45bbb2b 100644 --- a/frontend/src/context/Auth/useAuth.js +++ b/frontend/src/context/Auth/useAuth.js @@ -12,13 +12,6 @@ const useAuth = () => { const [loading, setLoading] = useState(true); useEffect(() => { - if ( - history.location.pathname === "/login" || - history.location.pathname === "/signup" - ) { - setLoading(false); - return; - } const token = localStorage.getItem("token"); if (token) { api.defaults.headers.Authorization = `Bearer ${JSON.parse(token)}`; @@ -67,7 +60,7 @@ const useAuth = () => { return Promise.reject(error); } ); - }, [history]); + }, []); const handleLogin = async (e, user) => { setLoading(true);