register
This commit is contained in:
parent
d6ac0fd8b4
commit
caa318f2c7
@ -5,16 +5,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">
|
||||
|
||||
<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>
|
||||
|
||||
@ -22,18 +14,23 @@
|
||||
<i class="fad fa-shield-alt"></i>
|
||||
Lentia – Yggdrasil
|
||||
</h1>
|
||||
<h3>Page d"inscription</h3>
|
||||
<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="text" placeholder="Nom d'utilisateur" id="username">
|
||||
<input type="password" placeholder="Mot de passe" id="password">
|
||||
<button id="registerBtn">
|
||||
<button onclick="register()">
|
||||
Créer mon compte !
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/izitoast/1.4.0/js/iziToast.min.js"></script>
|
||||
<script src="./register.js"></script>
|
||||
<style>
|
||||
div > input {
|
||||
width: 50%;
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,34 +1,20 @@
|
||||
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")
|
||||
}
|
||||
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 })
|
||||
}
|
||||
|
||||
btn.addEventListener("click", handleRegister)
|
||||
})
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user