fix: not redirecting away from login page when logged in

This commit is contained in:
canove
2020-10-26 14:45:15 -03:00
parent 8e655b89b1
commit 4e9d9f7d15

View File

@@ -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);