mirror of
https://github.com/kmitresse/Cards-Rush.git
synced 2026-05-16 09:05:28 +00:00
feet: dev-web - update reset password and token generation
This commit is contained in:
@@ -24,3 +24,17 @@ forgottenPasswordForm.addEventListener("submit", (event) => {
|
||||
|
||||
});
|
||||
|
||||
window.onload = function (){
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
let error = null;
|
||||
if (urlParams.has('error')) {
|
||||
error = urlParams.get('error');
|
||||
}
|
||||
console.log(error);
|
||||
if (error != null && error === "expired-token") {
|
||||
window.alert("Lien expiré, veuillez recommencer la procédure de récupération de mot de passe.");
|
||||
}
|
||||
if (error != null && error === "invalid-token") {
|
||||
window.alert("Lien invalide, veuillez recommencer la procédure de récupération de mot de passe.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ ResetPasswordForm.addEventListener("submit", function (event) {
|
||||
}).catch(error => {
|
||||
console.error("Error:", error);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -19,11 +19,12 @@
|
||||
<input type="email" id="email" name="email" required>
|
||||
<button type="submit">Send</button>
|
||||
</form>
|
||||
<%if(request.getParameter("error") != null){%>
|
||||
<%if(request.getParameter("error") != null && request.getParameter("error").equals("1")){%>
|
||||
<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>
|
||||
<script><%@include file="../static/js/forgotten-password.js"%></script>
|
||||
</html>
|
||||
|
||||
@@ -11,28 +11,10 @@
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<html>
|
||||
<head>
|
||||
<title>Recovery password</title>
|
||||
<title>Récupération du mot de passe</title>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<%
|
||||
DAO_JPA_RecoveryPasswordToken dao = null;
|
||||
RecoveryPasswordToken[] token;
|
||||
try {
|
||||
dao = new DAO_JPA_RecoveryPasswordToken();
|
||||
token = dao.findByField("token",request.getParameter("token"));
|
||||
} catch (DAOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (token.length == 0 || token[0] == null || token[0].getExpirationDate()== null) {%>
|
||||
<p> Lien invalide </p>
|
||||
<%
|
||||
} else if (token[0].getExpirationDate().compareTo(new java.util.Date()) >0){
|
||||
%>
|
||||
<p> Lien expiré </p>
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
<jsp:include page="../components/navbar.jsp"/>
|
||||
<h1>Récupération du mot de passe</h1>
|
||||
<form id="resetPasswordForm" action="reset-password" method="post">
|
||||
@@ -40,15 +22,12 @@
|
||||
<input type="password" id="newPassword" name="newPassword" required>
|
||||
<label for="confirmPassword">Confirmer le mot de passe</label>
|
||||
<input type="password" id="confirmPassword" name="confirmPassword" required>
|
||||
<% if (request.getParameter("error") != null && request.getParameter("error").equals("1")) {%>
|
||||
<% if (request.getParameter("error") != null && request.getParameter("error").equals("matching-password")) {%>
|
||||
<p>Les mots de passe ne correspondent pas</p>
|
||||
<% } %>
|
||||
<input type="hidden" name="token" value="${param.token}">
|
||||
<input type="submit" value="Valider">
|
||||
</form>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user