From 6112431d7b5573c425bbd10d25ed258ecd21aaab Mon Sep 17 00:00:00 2001 From: themrphantom Date: Tue, 26 Nov 2024 20:59:42 +0100 Subject: [PATCH] fix unable to login due to old cookies --- frontend/src/Components/Common/Login/Login.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/frontend/src/Components/Common/Login/Login.tsx b/frontend/src/Components/Common/Login/Login.tsx index 715f2dc..7edfcf8 100644 --- a/frontend/src/Components/Common/Login/Login.tsx +++ b/frontend/src/Components/Common/Login/Login.tsx @@ -17,9 +17,16 @@ const Login = (props: Props) => { const [disableLoginButton, setdisableLoginButton] = useState(false) const [username, setusername] = useState("") const [password, setpassword] = useState("") + + const clearCookies = () => { + //clear only username and password cookies + document.cookie = "token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; + document.cookie = "memberID=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; + } const login = () => { setdisableLoginButton(true); + clearCookies(); (function () { var cookies = document.cookie.split("; "); for (var c = 0; c < cookies.length; c++) { @@ -51,6 +58,7 @@ const Login = (props: Props) => { const loginOidc = async () => { setdisableLoginButton(true) + clearCookies(); doGetRequest("start-oidc").then(value => { if (value.code === 200) { console.log(value.content)