mirror of
https://github.com/kmitresse/Cards-Rush.git
synced 2026-05-16 17:11:48 +00:00
feat!(DevWeb): Add BulmaCSS, refacto, handle error on login pages, use bean, filters and tags
This commit is contained in:
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 13 KiB |
@@ -1,28 +0,0 @@
|
||||
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 => res.json())
|
||||
.then(user => sessionStorage.setItem("user", JSON.stringify(user)))
|
||||
.then(() => window.location.href = "./main-menu")
|
||||
.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.");
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
const session = JSON.parse(sessionStorage.getItem('session'));
|
||||
|
||||
url = new URL(window.location.href);
|
||||
url.protocol = 'ws:';
|
||||
|
||||
const websocket = new WebSocket(url);
|
||||
|
||||
websocket.onopen = () => {
|
||||
const linkUserSession = {
|
||||
type: 'linkUserSession',
|
||||
data: sessionStorage.getItem('user')
|
||||
}
|
||||
websocket.send(JSON.stringify(linkUserSession));
|
||||
}
|
||||
|
||||
websocket.onmessage = (event) => {
|
||||
const data = JSON.parse(event.data);
|
||||
|
||||
if (data.type === 'userList') {
|
||||
console.log(JSON.parse(data.data));
|
||||
}
|
||||
}
|
||||
|
||||
websocket.onclose = () => {}
|
||||
websocket.onerror = (error) => {}
|
||||
@@ -1,21 +0,0 @@
|
||||
const registerForm = document.getElementById("register-form");
|
||||
const confirmPassword = document.getElementById("confirmPassword");
|
||||
|
||||
registerForm.addEventListener("submit", (event) => {
|
||||
event.preventDefault();
|
||||
const formData = new FormData(registerForm);
|
||||
|
||||
const data = {};
|
||||
formData.forEach((value, key) => data[key] = value);
|
||||
|
||||
fetch(registerForm.getAttribute("action"), {
|
||||
method: registerForm.getAttribute("method"),
|
||||
headers: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify(data)
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(_ => {
|
||||
window.location.href = "./login"
|
||||
})
|
||||
.catch(error => console.error("Error: " + error))
|
||||
});
|
||||
Reference in New Issue
Block a user