diff --git a/data/static/register.html b/data/static/register.html index 6204575..1bbde48 100644 --- a/data/static/register.html +++ b/data/static/register.html @@ -5,16 +5,8 @@ - + Registration - - @@ -22,18 +14,23 @@ Lentia – Yggdrasil -

Page d"inscription

+

Page d'inscription


-
- + -
+ + \ No newline at end of file diff --git a/data/static/register.js b/data/static/register.js index 46d22d0..e90b9e5 100644 --- a/data/static/register.js +++ b/data/static/register.js @@ -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) -}) \ No newline at end of file +} \ No newline at end of file