mirror of
https://github.com/kmitresse/Cards-Rush.git
synced 2026-05-16 17:11:48 +00:00
draft: dev-web - forgotten password token
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
const forgottenPasswordForm = document.getElementById("forgottenPasswordForm");
|
||||
|
||||
forgottenPasswordForm.addEventListener("submit", (event) => {
|
||||
event.preventDefault();
|
||||
//Recuperer les données du formulaire
|
||||
const formData = new FormData(forgottenPasswordForm);
|
||||
const data = {};
|
||||
formData.forEach((value, key) => data[key] = value);
|
||||
//Recuperer l'URL de l'action et la methode
|
||||
const action = forgottenPasswordForm.getAttribute("action");
|
||||
const method = forgottenPasswordForm.getAttribute("method");
|
||||
//Redirection vers le servlet ForgottenPasswordServlet
|
||||
fetch(action, {
|
||||
headers: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify(data),
|
||||
method,
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
console.log(data);
|
||||
// if (data.status === 200) window.location.href = data.redirect;
|
||||
})
|
||||
.catch(error => console.error("Error:", error))
|
||||
|
||||
});
|
||||
|
||||
@@ -11,6 +11,19 @@
|
||||
<title>Forgotten Password</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<main>
|
||||
<h1>Forgotten Password</h1>
|
||||
<p>Entrer votre email pour recevoir un lien de récupération</p>
|
||||
<form id="forgottenPasswordForm" action="forgotten-password" method="post">
|
||||
<label for="email">Email</label>
|
||||
<input type="email" id="email" name="email" required>
|
||||
<button type="submit">Send</button>
|
||||
</form>
|
||||
<%if(request.getParameter("error") != null){%>
|
||||
<p>L'adresse mail insérée est incorrecte</p>
|
||||
<%} else if (request.getParameter("success") != null) {%>
|
||||
<p>Un email vous a été envoyé</p>
|
||||
<%}%>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user