fix: dev-web - fix expiration token

This commit is contained in:
kmitresse
2024-03-26 10:34:55 +01:00
parent ba90abdf14
commit bad26d50b0
2 changed files with 1 additions and 27 deletions
@@ -24,7 +24,7 @@ public class ResetPasswordServlet extends HttpServlet {
response.sendRedirect(request.getContextPath() + "/forgotten-password?error=invalid-token");
return;
}
if (token.getExpirationDate().compareTo(new java.util.Date()) > 0){
if (token.getExpirationDate().compareTo(new java.util.Date()) < 0){
response.sendRedirect(request.getContextPath() + "/forgotten-password?error=expired-token");
return;
}
@@ -1,29 +1,3 @@
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))
});
window.onload = function (){
const urlParams = new URLSearchParams(window.location.search);
let error = null;