Update register.html
This commit is contained in:
parent
4975f7e191
commit
57aeb47ed1
@ -3,10 +3,28 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<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/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">
|
<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>
|
||||||
|
|
||||||
@ -16,45 +34,62 @@
|
|||||||
</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 onclick="register()">
|
<button id="registerBtn">
|
||||||
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="https://cdnjs.cloudflare.com/ajax/libs/izitoast/1.4.0/js/iziToast.min.js"></script>
|
||||||
<style>
|
|
||||||
div > input {
|
|
||||||
width: 50%;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<script>
|
<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() {
|
async function handleRegister() {
|
||||||
const response = await fetch("https://yggdrasil.azures.fr/register", {
|
try {
|
||||||
method: "POST",
|
const response = await fetch("https://yggdrasil.azures.fr/register", {
|
||||||
headers: {
|
method: "POST",
|
||||||
"content-type": "application/json"
|
headers: {
|
||||||
},
|
"Content-Type": "application/json"
|
||||||
body: JSON.stringify({
|
},
|
||||||
email: email.value,
|
body: JSON.stringify({
|
||||||
username: username.value,
|
email: emailInput.value,
|
||||||
password: password.value
|
username: usernameInput.value,
|
||||||
})
|
password: passwordInput.value
|
||||||
})
|
})
|
||||||
const json = await response.json()
|
});
|
||||||
if (json.code != 200) {
|
|
||||||
return iziToast.error({ title: json.error, message: json.message })
|
const json = await response.json();
|
||||||
} else {
|
|
||||||
console.log(json)
|
if (json.code !== 200) {
|
||||||
return iziToast.success({ title: "Succès", message: json.message })
|
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>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Loading…
x
Reference in New Issue
Block a user