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 formVerificationCode = request.getParameter("verification_code");
|
||||
|
||||
if (verificationActions.verificationEntryExists(formUsername, formVerificationCode)) {
|
||||
//TODO check expiration date if "now" is more than 24h from the date in DB return error message
|
||||
|
||||
HttpSession session = request.getSession();
|
||||
session.setAttribute("username", formUsername);
|
||||
|
||||
response.sendRedirect("./resetPassword.jsp");
|
||||
printWriter.close();
|
||||
|
||||
if (verificationActions.verificationEntryExists(formUsername) && verificationActions.verificationCodeIsCorrect(formUsername, formVerificationCode)) {
|
||||
if (!verificationActions.verificationCodeHasExpired(formUsername)) {
|
||||
HttpSession session = request.getSession();
|
||||
session.setAttribute("username", formUsername);
|
||||
response.sendRedirect("./resetPassword.jsp");
|
||||
} else {
|
||||
logger.info("Verification code has expired!");
|
||||
response.sendRedirect("./expiredVerificationCode.jsp");
|
||||
}
|
||||
} else {
|
||||
request.getSession().setAttribute("message", "Username or verification code are not valid.");
|
||||
response.sendRedirect("./verify.jsp");
|
||||
// response.sendRedirect("./error.jsp"); or write a message in the session
|
||||
}
|
||||
printWriter.close();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue