Work verification code expiration
This commit is contained in:
parent
f5c1809efc
commit
9c446fadb2
|
@ -39,20 +39,20 @@ public class VerificationCodeServlet extends HttpServlet {
|
||||||
String formUsername = request.getParameter("username");
|
String formUsername = request.getParameter("username");
|
||||||
String formVerificationCode = request.getParameter("verification_code");
|
String formVerificationCode = request.getParameter("verification_code");
|
||||||
|
|
||||||
if (verificationActions.verificationEntryExists(formUsername, formVerificationCode)) {
|
if (verificationActions.verificationEntryExists(formUsername) && verificationActions.verificationCodeIsCorrect(formUsername, formVerificationCode)) {
|
||||||
//TODO check expiration date if "now" is more than 24h from the date in DB return error message
|
if (!verificationActions.verificationCodeHasExpired(formUsername)) {
|
||||||
|
HttpSession session = request.getSession();
|
||||||
HttpSession session = request.getSession();
|
session.setAttribute("username", formUsername);
|
||||||
session.setAttribute("username", formUsername);
|
response.sendRedirect("./resetPassword.jsp");
|
||||||
|
} else {
|
||||||
response.sendRedirect("./resetPassword.jsp");
|
logger.info("Verification code has expired!");
|
||||||
printWriter.close();
|
response.sendRedirect("./expiredVerificationCode.jsp");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
request.getSession().setAttribute("message", "Username or verification code are not valid.");
|
request.getSession().setAttribute("message", "Username or verification code are not valid.");
|
||||||
response.sendRedirect("./verify.jsp");
|
response.sendRedirect("./verify.jsp");
|
||||||
// response.sendRedirect("./error.jsp"); or write a message in the session
|
|
||||||
}
|
}
|
||||||
|
printWriter.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue