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