This commit is contained in:
Gilles Lazures 2026-01-19 20:26:58 +01:00
parent d6ac0fd8b4
commit caa318f2c7
2 changed files with 29 additions and 46 deletions

View File

@ -5,16 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css"> <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://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> <title>Registration</title>
<style>
div > input {
width: 50%;
display: block;
margin-bottom: 10px;
}
</style>
</head> </head>
<body> <body>
@ -22,18 +14,23 @@
<i class="fad fa-shield-alt"></i> <i class="fad fa-shield-alt"></i>
Lentia Yggdrasil Lentia Yggdrasil
</h1> </h1>
<h3>Page d"inscription</h3> <h3>Page d'inscription</h3>
<hr> <hr>
<div> <div>
<input type="email" placeholder="Adresse mail" id="email"> <input type="email" placeholder="Adresse mail" id="email">
<input type="text" placeholder="Nom d"utilisateur" id="username"> <input type="text" placeholder="Nom d'utilisateur" id="username">
<input type="password" placeholder="Mot de passe" id="password"> <input type="password" placeholder="Mot de passe" id="password">
<button id="registerBtn"> <button onclick="register()">
Créer mon compte ! Créer mon compte !
</button> </button>
</div> </div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/izitoast/1.4.0/js/iziToast.min.js"></script>
<script src="./register.js"></script> <script src="./register.js"></script>
<style>
div > input {
width: 50%;
}
</style>
</body> </body>
</html> </html>

View File

@ -1,34 +1,20 @@
document.addEventListener("DOMContentLoaded", () => { async function register() {
const btn = document.getElementById("registerBtn") const response = await fetch("https://yggdrasil.azures.fr/register", {
const emailInput = document.getElementById("email") method: "POST",
const usernameInput = document.getElementById("username") headers: {
const passwordInput = document.getElementById("password") "content-type": "application/json"
},
async function handleRegister() { body: JSON.stringify({
try { email: email.value,
const response = await fetch("https://yggdrasil.azures.fr/register", { username: username.value,
method: "POST", password: password.value
headers: { })
"Content-Type": "application/json" })
}, const json = await response.json()
body: JSON.stringify({ if (json.code != 200) {
email: emailInput.value, return iziToast.error({ title: json.error, message: json.message })
username: usernameInput.value, } else {
password: passwordInput.value console.log(json)
}) return iziToast.success({ title: "Succès", message: json.message })
})
const json = await response.json()
if (json.code !== 200) {
alert((json.error || "Erreur") + (json.message || "Une erreur est survenue"))
} else {
alert("Succès")
}
} catch (error) {
alert("Une erreur est survenue")
}
} }
}
btn.addEventListener("click", handleRegister)
})