mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-20 04:39:20 +00:00
fix: not redirecting away from login page when logged in
This commit is contained in:
@@ -12,13 +12,6 @@ const useAuth = () => {
|
|||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
|
||||||
history.location.pathname === "/login" ||
|
|
||||||
history.location.pathname === "/signup"
|
|
||||||
) {
|
|
||||||
setLoading(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const token = localStorage.getItem("token");
|
const token = localStorage.getItem("token");
|
||||||
if (token) {
|
if (token) {
|
||||||
api.defaults.headers.Authorization = `Bearer ${JSON.parse(token)}`;
|
api.defaults.headers.Authorization = `Bearer ${JSON.parse(token)}`;
|
||||||
@@ -67,7 +60,7 @@ const useAuth = () => {
|
|||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}, [history]);
|
}, []);
|
||||||
|
|
||||||
const handleLogin = async (e, user) => {
|
const handleLogin = async (e, user) => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user