From b9bc741fc6d5c802d0ffd27947606953c3e95553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luc=C3=A0s?= Date: Wed, 20 Mar 2024 23:56:40 +0100 Subject: [PATCH] fix(DevWeb): Remove endpoint link for login --- S2/DevWeb/Projet/src/main/webapp/WEB-INF/static/js/login.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/S2/DevWeb/Projet/src/main/webapp/WEB-INF/static/js/login.js b/S2/DevWeb/Projet/src/main/webapp/WEB-INF/static/js/login.js index b9c5a69..011557e 100644 --- a/S2/DevWeb/Projet/src/main/webapp/WEB-INF/static/js/login.js +++ b/S2/DevWeb/Projet/src/main/webapp/WEB-INF/static/js/login.js @@ -7,10 +7,9 @@ loginForm.addEventListener("submit", (event) => { formData.forEach((value, key) => data[key] = value); const action = loginForm.getAttribute("action") - const endpoint = loginForm.getAttribute("data-login-endpoint"); const method = loginForm.getAttribute("method") - fetch(endpoint, { + fetch(action, { headers: {"Content-Type": "application/json"}, body: JSON.stringify(data), method, @@ -18,7 +17,7 @@ loginForm.addEventListener("submit", (event) => { .then(res => res.json()) .then(data => { console.log(data); - if (data.status == 200) window.location.href = action; + if (data.status === 200 && data.nextUrl) window.location.href = data.nextUrl; }) .catch(error => console.error("Error:", error)) ;