From f34fec6d27f5728caa5c701d334f86388331737e Mon Sep 17 00:00:00 2001 From: Luxshan2000 Date: Wed, 1 Nov 2023 16:46:05 +0530 Subject: [PATCH] debugging --- webapp/src/utils/logout.js | 21 +++++++++++++++------ webapp/src/views/Login.js | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) 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}) } },[])