mirror of
https://github.com/kmitresse/Cards-Rush.git
synced 2026-07-09 13:27:45 +00:00
34 lines
1.0 KiB
JavaScript
34 lines
1.0 KiB
JavaScript
const loginForm = document.getElementById("login-form");
|
|
|
|
loginForm.addEventListener("submit", (event) => {
|
|
event.preventDefault();
|
|
|
|
const formData = new FormData(loginForm);
|
|
const data = {};
|
|
formData.forEach((value, key) => data[key] = value);
|
|
|
|
fetch(loginForm.getAttribute("action"), {
|
|
headers: {"Content-Type": "application/json"}, body: JSON.stringify(data), method: loginForm.getAttribute("method"),
|
|
})
|
|
.then(res => {
|
|
if (res.ok) {
|
|
window.location.href = "./main-menu";
|
|
}
|
|
else {
|
|
// TODO Display red inputs
|
|
}
|
|
})
|
|
.catch(error => console.error("Error:", error));
|
|
});
|
|
|
|
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
if (urlParams.has('success')) {
|
|
if (urlParams.get('success') === "account-created") {
|
|
window.alert("Compte créé avec succès.");
|
|
}
|
|
if (urlParams.get('success') === "password-reseted") {
|
|
window.alert("Mot de passe réinitialisé avec succès.");
|
|
}
|
|
}
|