Update register.html

This commit is contained in:
Gilles Lazures 2026-01-19 20:19:19 +01:00
parent 4975f7e191
commit 57aeb47ed1

View File

@ -3,10 +3,28 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Security-Policy" content="
default-src 'self';
script-src 'self' https://cdnjs.cloudflare.com;
style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://cdnjs.cloudflare.com https://fonts.googleapis.com;
font-src 'self' https://cdn.jsdelivr.net https://cdnjs.cloudflare.com;
connect-src 'self' https://yggdrasil.azures.fr;
">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/hung1001/font-awesome-pro@4cac1a6/css/all.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/izitoast/1.4.0/css/iziToast.min.css">
<title>Registration</title>
<style>
div > input {
width: 50%;
display: block;
margin-bottom: 10px;
}
</style>
</head>
<body>
@ -16,45 +34,62 @@
</h1>
<h3>Page d'inscription</h3>
<hr>
<div>
<input type="email" placeholder="Adresse mail" id="email">
<input type="text" placeholder="Nom d'utilisateur" id="username">
<input type="password" placeholder="Mot de passe" id="password">
<button onclick="register()">
<button id="registerBtn">
Créer mon compte !
</button>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/izitoast/1.4.0/js/iziToast.min.js"></script>
<style>
div > input {
width: 50%;
}
</style>
<script>
document.addEventListener('DOMContentLoaded', () => {
const btn = document.getElementById('registerBtn');
const emailInput = document.getElementById('email');
const usernameInput = document.getElementById('username');
const passwordInput = document.getElementById('password');
async function register() {
const response = await fetch("https://yggdrasil.azures.fr/register", {
method: "POST",
headers: {
"content-type": "application/json"
},
body: JSON.stringify({
email: email.value,
username: username.value,
password: password.value
})
})
const json = await response.json()
if (json.code != 200) {
return iziToast.error({ title: json.error, message: json.message })
} else {
console.log(json)
return iziToast.success({ title: "Succès", message: json.message })
async function handleRegister() {
try {
const response = await fetch("https://yggdrasil.azures.fr/register", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
email: emailInput.value,
username: usernameInput.value,
password: passwordInput.value
})
});
const json = await response.json();
if (json.code !== 200) {
iziToast.error({
title: json.error || "Erreur",
message: json.message || "Une erreur est survenue"
});
} else {
iziToast.success({
title: "Succès",
message: json.message
});
}
} catch (error) {
iziToast.error({
title: "Erreur",
message: "Impossible de contacter le serveur."
});
}
}
}
btn.addEventListener('click', handleRegister);
});
</script>
</body>
</html>