Fix redirect when user does not exist

This commit is contained in:
Sofia Baltzi 2017-10-24 11:23:11 +00:00
parent 12816439bd
commit e3395073ab
1 changed files with 5 additions and 4 deletions

View File

@ -56,7 +56,7 @@ public class ForgotPasswordServlet extends HttpServlet {
try {
String username = ldapActions.getUsername(formEmail);
if (username == null) {
if (username == null || username.isEmpty()) {
request.getSession().setAttribute("message", "User does not exist.");
response.sendRedirect("./forgotPassword.jsp");
@ -84,6 +84,9 @@ public class ForgotPasswordServlet extends HttpServlet {
String verificationCodeSubject = "Your OpenAIRE password reset request";
emailSender.sendEmail(formEmail, verificationCodeSubject, verificationCodeMsg);
response.setContentType("text/html");
response.sendRedirect("./verify.jsp");
}
} catch (LDAPException ldape) {
@ -94,9 +97,7 @@ public class ForgotPasswordServlet extends HttpServlet {
request.getSession().setAttribute("message", "Error sending email.");
response.sendRedirect("./forgotPassword.jsp");
}
response.setContentType("text/html");
response.sendRedirect("./verify.jsp");
}
}