diff --git a/webapp/src/utils/logout.js b/webapp/src/utils/logout.js index 4dc338e..429bb2f 100644 --- a/webapp/src/utils/logout.js +++ b/webapp/src/utils/logout.js @@ -3,14 +3,23 @@ import axios from 'axios'; import { BACKEND_URL } from './constants'; export const logout = () => { - axios.defaults.withCredentials = true - console.log("clciked") - // Add logout functionality here - axios.post(`${BACKEND_URL}/api/auth/logout`) - .then((res)=>{ + // axios.defaults.withCredentials = true + // console.log("clciked") + // // Add logout functionality here + // axios.post(`${BACKEND_URL}/api/auth/logout`) + // .then((res)=>{ + // window.location.reload(true); + // window.location.href = "/"; + // }).catch((err)=>console.log(err)) + try{ + localStorage.removeItem("token"); window.location.reload(true); window.location.href = "/"; - }).catch((err)=>console.log(err)) + + } + catch(err){ + console.log("Error") + } }; diff --git a/webapp/src/views/Login.js b/webapp/src/views/Login.js index 868f2c8..505abe3 100644 --- a/webapp/src/views/Login.js +++ b/webapp/src/views/Login.js @@ -27,7 +27,7 @@ export default function Login() { useEffect(()=>{ - if(getSessionCookie("token")){ + if(localStorage.getItem("token")){ navigate("/dashboard", {replace:true}) } },[])