From 30163840d81f702abf609d954c058fd0bb7b6462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luc=C3=A0s?= Date: Fri, 12 Apr 2024 10:07:54 +0200 Subject: [PATCH] draft(DevWeb): Try to resolve redirection --- .../Projet/src/main/webapp/static/js/login.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/S2/DevWeb/Projet/src/main/webapp/static/js/login.js b/S2/DevWeb/Projet/src/main/webapp/static/js/login.js index c6d6bd6..e6fd2f4 100644 --- a/S2/DevWeb/Projet/src/main/webapp/static/js/login.js +++ b/S2/DevWeb/Projet/src/main/webapp/static/js/login.js @@ -8,12 +8,16 @@ loginForm.addEventListener("submit", (event) => { formData.forEach((value, key) => data[key] = value); fetch(loginForm.getAttribute("action"), { - headers: {"Content-Type": "application/json"}, - body: JSON.stringify(data), - method: loginForm.getAttribute("method"), + headers: {"Content-Type": "application/json"}, body: JSON.stringify(data), method: loginForm.getAttribute("method"), }) - .then(res => res.json()) - .then(d => window.location.href = "./main-menu") + .then(res => { + if (res.ok) { + window.location.href = "./main-menu"; + } + else { + // TODO Display red inputs + } + }) .catch(error => console.error("Error:", error)); });