74 lines
2.4 KiB
HTML
74 lines
2.4 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<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/gh/hung1001/font-awesome-pro@4cac1a6/css/all.css">
|
||
|
||
<title>Registration</title>
|
||
|
||
<style>
|
||
div > input {
|
||
width: 50%;
|
||
display: block;
|
||
margin-bottom: 10px;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
|
||
<h1>
|
||
<i class="fad fa-shield-alt"></i>
|
||
Lentia – Yggdrasil
|
||
</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 id="registerBtn">
|
||
Créer mon compte !
|
||
</button>
|
||
</div>
|
||
|
||
<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 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) {
|
||
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)
|
||
})
|
||
</script>
|
||
</body>
|
||
</html> |